結果

問題 No.2924 <===Super Spaceship String===>
コンテスト
ユーザー VvyLw
提出日時 2024-10-14 12:31:06
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 973 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,408 ms
コンパイル使用メモリ 183,700 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-05 13:40:38
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#ifdef local
#include <C++/core/io/debug_print.hpp>
#else
#define dump(...) void(0);
#endif

#include <iostream>
#include <ranges>
#include <stack>
namespace man {

}
int main() {
    std::cin.tie(nullptr) -> sync_with_stdio(false);
    using namespace std::views;
    std::string s;
    std::cin >> s;
    std::stack<char> sk;
    int st = 0;
    for(const auto &c: s) {
        if(c == '<') {
            st++;
        }
        if(!sk.empty() && c == '>') {
            if(st == 0 || sk.top() != '=') {
                sk.emplace(c);
                st = 0;
                continue;
            }
            while(st > 0 && sk.top() == '=') {
                sk.pop();
            }
            sk.pop();
            st--;
            continue;
        }
        sk.emplace(c);
    }
    std::cout << sk.size() << '\n';
}
0