結果
問題 |
No.2924 <===Super Spaceship String===>
|
ユーザー |
![]() |
提出日時 | 2024-10-12 18:32:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 813 bytes |
コンパイル時間 | 2,072 ms |
コンパイル使用メモリ | 197,080 KB |
最終ジャッジ日時 | 2025-02-24 18:53:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); string s; cin >> s; vector<pair<char, int>> rle; for (int i = 0; i < s.size(); i++) { if (rle.empty() || rle.back().first != s[i]) { rle.push_back({s[i], 1}); } else { rle.back().second++; } } int l = rle.size(); vector<pair<char, int>> st; for (auto [c, cnt] : rle) { if (c == '>' && st.size() > 1 && st.back().first == '=' && st[st.size() - 2].first == '<') { st.pop_back(); st.back().second--; if (st.back().second == 0) { st.pop_back(); } if (cnt > 1) { st.push_back({c, cnt - 1}); } } else { st.push_back({c, cnt}); } } int ans = 0; for (auto [c, cnt] : st) { ans += cnt; } cout << ans << endl; }