結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
|
提出日時 | 2024-10-12 15:02:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,088 bytes |
コンパイル時間 | 1,677 ms |
コンパイル使用メモリ | 173,248 KB |
実行使用メモリ | 9,008 KB |
最終ジャッジ日時 | 2024-10-16 17:53:41 |
合計ジャッジ時間 | 2,443 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long signed main() { string s; cin >> s; int n = s.size(); deque<pair<int,char>> q; for(int i = 0; i < n; i++) { if(s[i] != '>') { int l = q.size(); if(l == 0) q.push_back({1,s[i]}); else if(q.back().second == s[i]) q.back().first++; else q.push_back({1,s[i]}); } else { int l = q.size(); if(l == 0) q.push_back({1,s[i]}); else if(l == 1) { if(q.back().second == s[i]) q.back().first++; else q.push_back({1,s[i]}); } else { if(q.back().second != '=') { if(q.back().second == s[i]) q.back().first++; else q.push_back({1,s[i]}); } else { int x = q.back().first; q.pop_back(); if(q.back().second != '<') { q.push_back({x,'='}); if(q.back().second == s[i]) q.back().first++; else q.push_back({1,s[i]}); } else { q.back().first--; if(q.back().first == 0) q.pop_back(); } } } } } int ans = 0; while(q.size() > 0) { ans+=q.front().first; q.pop_front(); } cout << ans << endl; }