結果

問題 No.2924 <===Super Spaceship String===>
ユーザー GOTKAKO
提出日時 2024-10-12 14:48:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 206,876 KB
最終ジャッジ日時 2025-02-24 17:43:28
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    int N = s.size();
    set<int> S;
    for(int i=0; i<N; i++) S.insert(i);

    stack<int> st;
    for(int i=0; i<N; i++){
        if(s.at(i) == '<'){st.push(i); continue;}
        if(s.at(i) == '=') continue;
        if(st.size()){
            int l = st.top(); st.pop();
            auto itr = S.lower_bound(l);
            vector<int> era;
            while(itr != S.end()){
                int p = *itr;
                if(p > i) break;
                era.push_back(p);
                itr++;
            }
            if(era.size() == 2){
                while(st.size()) st.pop();
            }
            else for(auto e : era) S.erase(e);
        }
    }
    cout << S.size() << endl;
}

0