結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:00:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 777 ms |
コンパイル使用メモリ | 72,436 KB |
最終ジャッジ日時 | 2025-02-24 17:49:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream> #include <vector> using Int = long long; int main() { std::string S; std::cin >> S; int N = S.size(); std::vector<char> sta; int cnt = 0; for (int i = 0; i < N; ++i) { if (S[i] == '<' || S[i] == '=') { sta.push_back(S[i]); cnt += S[i] == '<'; } if (S[i] == '>') { if (cnt && sta.back() == '=') { while (sta.back() != '<') sta.pop_back(); sta.pop_back(); --cnt; } else { sta.push_back(S[i]); cnt = 0; } } } std::cout << sta.size() << std::endl; }