結果
問題 |
No.2924 <===Super Spaceship String===>
|
ユーザー |
|
提出日時 | 2024-10-12 15:30:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,351 bytes |
コンパイル時間 | 2,349 ms |
コンパイル使用メモリ | 204,452 KB |
最終ジャッジ日時 | 2025-02-24 18:04:01 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; vector<pair<char, int>> T; T.push_back({S[0], 0}); for (int i = 1; i < (int)S.size(); i++) { if (S[i - 1] == '=' && S[i] == '=') { // } else { T.push_back({S[i], i}); } } stack<pair<char, int>> st; vector<int> imos((int)S.size() + 1, 0); cout << endl; for (int i = 0; i < (int)T.size(); i++) { st.push(T[i]); while ((int)st.size() >= 3) { auto [a, x] = st.top(); st.pop(); auto [b, y] = st.top(); st.pop(); auto [c, z] = st.top(); st.pop(); string abc = ""; abc += c; abc += b; abc += a; // cout << "### " << abc << endl; if (abc == "<=>") { imos[z]++; imos[x + 1]--; } else { st.push({c, z}); st.push({b, y}); st.push({a, x}); break; } } } for (int i = 0; i < (int)S.size(); i++) { imos[i + 1] += imos[i]; } int ans = 0; for (int i = 0; i < (int)S.size(); i++) { if (imos[i] == 0) { ans++; } } cout << ans << endl; return 0; }