結果

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

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    stack<string> st;
    st.emplace("");
    for(auto &&c : s){
        if(c == '<'){
            st.emplace("");
            st.top() += c;
        }else if(c == '>'){
            if(st.top()[0] == '<' && st.top().back() == '='){
                st.pop();
            }else{
                st.emplace("");
                st.top() += c;
            }
        }else st.top() += c;
    }
    int ans = 0;
    while(!st.empty()){
        ans += st.top().size();
        st.pop();
    }
    cout << ans << '\n';
}
0