結果
| 問題 | No.2924 <===Super Spaceship String===> | 
| コンテスト | |
| ユーザー |  cled0328 | 
| 提出日時 | 2024-10-12 15:11:20 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 20 ms / 2,000 ms | 
| コード長 | 571 bytes | 
| コンパイル時間 | 2,085 ms | 
| コンパイル使用メモリ | 198,028 KB | 
| 最終ジャッジ日時 | 2025-02-24 17:54:34 | 
| ジャッジサーバーID (参考情報) | judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    stack<char> q;
    for(auto i:s){
        if(i=='>'){
            while(!q.empty()&&q.top()=='t')q.pop();
            if(!q.empty()&&q.top()=='s')q.pop();
            else q.push('>');
        }else if(i=='='){
            if(!q.empty()&&(q.top()=='<')){
                q.top()='s';
                q.push('t');
            }else if(!q.empty()&&(q.top()=='t'))q.push('t');
            else q.push('=');
        }else{
            q.push('<');
        }
    }
    cout<<q.size()<<"\n";
}
            
            
            
        