結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
|
提出日時 | 2024-12-05 17:49:00 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 78,564 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-05 17:50:17 |
合計ジャッジ時間 | 1,462 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream>#include <cstdint>#include <vector>#include <stack>using namespace std;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);string S;cin >> S;int32_t i, j, removed = 0;stack<int32_t> s;for (i = j = 0; i != S.size(); ++i)switch (S[i]){case '<':s.push(j), j = 0;break;case '=':++j;break;case '>':if (!s.empty()){if (j != 0) removed += j + 2, j = s.top(), s.pop();else while (!s.empty()) s.pop();}break;}cout << S.size() - removed << '\n';return 0;}