結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー 2251799813685248
提出日時 2026-11-26 16:15:20
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 798 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 78 ms
コンパイル使用メモリ 64,472 KB
実行使用メモリ 515,312 KB
最終ジャッジ日時 2026-11-26 16:15:54
合計ジャッジ時間 33,644 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 11 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.setrecursionlimit(10**7)

stk = []
Q = 0
Q2 = 0
output = 0
def f():
    global Q, output
    if not Q:
        return
    Q -= 1
    q = input().split()
    erased = False
    if q[0] == "1":
        c = q[1]
        stk.append(c)
        if len(stk) >= 3 and c == ")":
            if stk[-1] == ")" and stk[-2] == "|" and stk[-3] == "(":
                erased = True
                stk.pop()
                stk.pop()
                stk.pop()
        print("No" if len(stk) else "Yes")
        output += 1
        f()
        if erased:
            stk.append("(")
            stk.append("|")
            stk.append(")")
        stk.pop()
        if output < Q2:
            print("No" if len(stk) else "Yes")
            output += 1
            f()
Q = int(input())
Q2 = Q
f()

0