結果
問題 |
No.2924 <===Super Spaceship String===>
|
ユーザー |
![]() |
提出日時 | 2024-10-18 00:15:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 965 bytes |
コンパイル時間 | 3,474 ms |
コンパイル使用メモリ | 251,684 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-18 00:15:58 |
合計ジャッジ時間 | 4,437 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { string s; cin >> s; stack<pair<char, int>> st; for (char c : s) { bool flag = false; if (st.size() >= 2) { auto [c1, cnt1] = st.top(); st.pop(); auto [c2, cnt2] = st.top(); st.pop(); if (c2 == '<' && c1 == '=' && c == '>') { flag = true; } else { st.push({ c2, cnt2 }); st.push({ c1, cnt1 }); } } if (!flag) { if (c == '=' && !st.empty() && st.top().first == '=') { st.top().second++; } else { st.push({ c, 1 }); } } Debug(st); } int ans = 0; while (!st.empty()) { auto [c, cnt] = st.top(); st.pop(); ans += cnt; } cout << ans << endl; return 0; }