結果
問題 | No.2924 <===Super Spaceship String===> |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:03:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 901 bytes |
コンパイル時間 | 2,944 ms |
コンパイル使用メモリ | 249,672 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-16 17:53:43 |
合計ジャッジ時間 | 3,660 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, x, y) for (auto i = (x); i < (y); i++) #define RREP(i, x, y) for (auto i = (y) - 1; (x) <= i; i--) #define ALL(x) (x).begin(), (x).end() #pragma GCC optimize("O3") int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string S; cin >> S; int N = ssize(S); stack<char> s; stack<char> t; REP(i, 0, N){ if(S[i] == '<'){ s.push('<'); t.push('<'); } if(S[i] == '='){ s.push('='); } if(S[i] == '>'){ if(!s.empty() && !t.empty() && s.top() == '=' && t.top() == '<'){ while(s.top() == '='){ s.pop(); } s.pop(); t.pop(); }else{ s.push('>'); t.push('>'); } } } cout << ssize(s) << "\n"; return 0; } /* File : ~/yukicoder/midoriika_3rd/F.cpp Date : 2024/10/12 Time : 14:46:06 */