結果

問題 No.2924 <===Super Spaceship String===>
ユーザー Tatsu_mr
提出日時 2024-10-12 15:17:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 2,849 ms
コンパイル使用メモリ 251,144 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-16 17:54:17
合計ジャッジ時間 3,621 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using namespace std;

using lint = long long;
using ld = long double;

int main() {
    string s;
    cin >> s;
    stack<int> st1, st2, st3;
    st1.emplace(-1);
    st2.emplace(-1);
    st3.emplace(-1);
    rep(i, (int)s.size()) {
        if (s[i] == '<') {
            st1.emplace(i);
        } else if (s[i] == '=') {
            st2.emplace(i);
        } else {
            int x = st1.top(), y = st2.top(), z = st3.top();
            if (z < x && z < y && x < y) {
                while (st2.top() > st1.top()) {
                    st2.pop();
                }
                st1.pop();
            } else {
                st3.emplace(i);
            }
        }
    }
    cout << (int)st1.size() + (int)st2.size() + (int)st3.size() - 3 << endl;
}
0