結果
| 問題 |
No.2924 <===Super Spaceship String===>
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 17:36:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 793 bytes |
| コンパイル時間 | 2,126 ms |
| コンパイル使用メモリ | 196,528 KB |
| 最終ジャッジ日時 | 2025-02-24 18:51:22 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
vector<pair<int,int>> st;
rep(i,s.size()){
if(s[i]=='>'){
if(st.size()>=2 && st[st.size()-1].first=='=' && st[st.size()-2].first=='<'){
st.pop_back();
st.pop_back();
continue;
}
}
else if(s[i]=='='){
if(st.size()>=1 && st.back().first=='='){
st.back().second++;
continue;
}
}
st.push_back(make_pair(s[i],1));
}
int ans = 0;
rep(i,st.size()) ans += st[i].second;
cout << ans << endl;
}