結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー カプモカ
提出日時 2026-04-18 00:44:42
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 557 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 629 ms
コンパイル使用メモリ 20,796 KB
実行使用メモリ 40,540 KB
最終ジャッジ日時 2026-04-18 00:45:45
合計ジャッジ時間 13,995 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 9 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

Q = int(input().strip())

st = [''] * 800005
history_sz = [0] * 800005
sz = 0
L = 0

for q in range(Q):
    data = input().split()
    if data[0] == "1":
        L += 1
        st[sz] = data[1]
        sz += 1
        if sz >= 3 and st[sz-3] == '(' and st[sz-2] == '|' and st[sz-1] == ')':
            sz -= 3
        history_sz[L] = sz

        if sz == 0:
            print("Yes")
        else:
            print("No")

    else:
        L -= 1
        sz = history_sz[L]

        if sz == 0:
            print("Yes")
        else:
            print("No")
0