結果

問題 No.2924 <===Super Spaceship String===>
ユーザー akiaki
提出日時 2024-10-12 17:36:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 203,996 KB
実行使用メモリ 8,148 KB
最終ジャッジ日時 2024-10-16 17:55:57
合計ジャッジ時間 2,484 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 4 ms
5,248 KB
testcase_08 AC 4 ms
5,248 KB
testcase_09 AC 4 ms
5,248 KB
testcase_10 AC 13 ms
8,148 KB
testcase_11 AC 6 ms
5,248 KB
testcase_12 AC 4 ms
5,248 KB
testcase_13 AC 9 ms
8,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0