結果
| 問題 |
No.2924 <===Super Spaceship String===>
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-10-12 18:39:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 852 bytes |
| コンパイル時間 | 2,101 ms |
| コンパイル使用メモリ | 197,480 KB |
| 最終ジャッジ日時 | 2025-02-24 18:54:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#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] || 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.empty() && st.back().first == '=') {
st.back().second += cnt;
} else {
st.push_back({c, cnt});
}
if (st.size() >= 3 && st[st.size() - 3].first == '<' &&
st[st.size() - 2].first == '=' && st[st.size() - 1].first == '>') {
st.pop_back();
st.pop_back();
st.pop_back();
}
}
int ans = 0;
for (auto [c, cnt] : st) {
ans += cnt;
}
cout << ans << endl;
}
eve__fuyuki