結果

問題 No.2924 <===Super Spaceship String===>
ユーザー hanagehanage
提出日時 2024-10-12 15:30:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 2,427 ms
コンパイル使用メモリ 212,464 KB
実行使用メモリ 12,484 KB
最終ジャッジ日時 2024-10-12 15:31:01
合計ジャッジ時間 3,076 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    string S;
    cin >> S;
    vector<pair<char, int>> T;
    T.push_back({S[0], 0});
    for (int i = 1; i < (int)S.size(); i++) {
        if (S[i - 1] == '=' && S[i] == '=') {
            //
        } else {
            T.push_back({S[i], i});
        }
    }
    stack<pair<char, int>> st;
    vector<int> imos((int)S.size() + 1, 0);
    cout << endl;
    for (int i = 0; i < (int)T.size(); i++) {
        st.push(T[i]);
        while ((int)st.size() >= 3) {
            auto [a, x] = st.top();
            st.pop();
            auto [b, y] = st.top();
            st.pop();
            auto [c, z] = st.top();
            st.pop();
            string abc = "";
            abc += c;
            abc += b;
            abc += a;
            // cout << "### " << abc << endl;
            if (abc == "<=>") {
                imos[z]++;
                imos[x + 1]--;
            } else {
                st.push({c, z});
                st.push({b, y});
                st.push({a, x});
                break;
            }
        }
    }
    for (int i = 0; i < (int)S.size(); i++) {
        imos[i + 1] += imos[i];
    }
    int ans = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        if (imos[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
0