結果
| 問題 | No.2924 <===Super Spaceship String===> | 
| コンテスト | |
| ユーザー |  はるお味 | 
| 提出日時 | 2024-10-14 09:23:45 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 17 ms / 2,000 ms | 
| コード長 | 901 bytes | 
| コンパイル時間 | 3,219 ms | 
| コンパイル使用メモリ | 249,452 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-16 17:56:32 | 
| 合計ジャッジ時間 | 3,485 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
int main() {
  string s;cin>>s;
  int n=s.size();
  int ans=n;
  int b=0,a,mod=-1;
  stack<int> B;
  rep(i,n){
    //cout<<B.size()<<' '<<ans<<' '<<b<<endl;
    if(s[i]=='<'){
      if(mod==1){B.push(b);}mod=1; b=0;}
    if(s[i]=='>'){
      if(b>0){ans-=(b+2);
        if(B.size()>0){
          b=B.top();B.pop();
        }
        else{
          b=0;mod=-1;
        }
      }
      else{
        b=0;
        while(B.size()>0){B.pop();}
        mod=-1;
      }
    }
    if(s[i]=='='&&mod==1){b++;}
  }
  cout<<ans<<endl;
}
            
            
            
        