結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-12 16:09:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 87,644 KB |
実行使用メモリ | 12,608 KB |
最終ジャッジ日時 | 2024-10-16 17:55:13 |
合計ジャッジ時間 | 1,351 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <tuple> #include <cstdio> #include <cmath> #include <cassert> #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; signed main() { string s; cin >> s; typedef pair<char, int> P; vector<P> stk; for (int i = 0; i < s.length(); i++) { if (s[i] == '<' || s[i] == '>') { stk.push_back(P(s[i], 1)); } else { if (stk.size() > 0 && stk[stk.size() - 1].first == '=') stk[stk.size() - 1].second++; else stk.push_back(P(s[i], 1)); } if (stk.size() >= 3 && stk[stk.size() - 3].first == '<' && stk[stk.size() - 2].first == '=' && stk[stk.size() - 1].first == '>') { stk.pop_back(); stk.pop_back(); stk.pop_back(); } } int ans = 0, i; rep(i, stk.size()) { ans += stk[i].second; } cout << ans << endl; return 0; }