結果

問題 No.2924 <===Super Spaceship String===>
ユーザー mahiro0o0o0
提出日時 2024-10-12 16:28:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,671 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 3,906 ms
コンパイル使用メモリ 232,244 KB
実行使用メモリ 7,512 KB
最終ジャッジ日時 2024-10-16 17:55:36
合計ジャッジ時間 7,593 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, k, n) for (ll i = (ll)(k); i < (ll)(n); i++)
#define repM(i, k, n) for (ll i = (ll)(k); i > (ll)(n); i--)
#define all(v) v.begin(), v.end()
using ll = long long;
ll mod = 998244353;

int main() {
  string S, T = "";
  ll start = 0, eq = 0;
  cin >> S;
  stack<ll> A, B;
  A.push(0);
  B.push(0);
  rep(i, S.size()){
    T.push_back(S[i]);
    if(T[T.size()-1] == '<'){
      start = T.size();
      eq = 0;
      A.push(T.size());
    } else if(T[T.size()-1] == '='){
      if(start > 0){
        eq++;
      }
    } else {
      if(start > 0 && eq > 0){
        T = T.substr(0, start-1);
        A.pop();
        if(A.top() > B.top()){
          start = A.top();
          eq = T.size() - start;
        } else {
          start = 0;
          eq = 0;
        }
      } else {
        start = 0;
        B.push(T.size());
      }
      
    }
  }

  cout << T.size();
}
0