結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー potato1938
提出日時 2026-04-18 09:19:47
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,432 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 201 ms
コンパイル使用メモリ 85,284 KB
実行使用メモリ 209,580 KB
最終ジャッジ日時 2026-04-18 09:20:38
合計ジャッジ時間 39,423 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

q=int(input())
anslist=list()
pointer=0
for frif in range(q):
    query=list(input().split())
    if query[0]=="1":
        
        if pointer==0:
            if query[1]=="(":
                anslist.append([0,1,0,0])
            elif query[1]=="|":
                anslist.append([0,0,1,0])
            else:
                anslist.append([0,0,0,1])
        else:
            mae=anslist[pointer-1]
            try:
                anslist[pointer]=[mae[0],mae[1],mae[2],mae[3]]
            except:
            	anslist.append([mae[0],mae[1],mae[2],mae[3]])
            if query[1]=="(":
                anslist[pointer][1]+=1
            if query[1]=="|":
                anslist[pointer][2]+=1
            if query[1]==")":
                anslist[pointer][3]+=1
            if anslist[pointer][1]<anslist[pointer][2] or anslist[pointer][2]<anslist[pointer][3] or anslist[pointer][1]<anslist[pointer][3]:
                anslist[pointer][0]=-1
        if anslist[pointer][1]==anslist[pointer][2]==anslist[pointer][3] and anslist[pointer][0]!=-1:
            print("Yes")
        else:
            print("No")
        pointer+=1
    else:
        
        pointer-=2
        if pointer==-1:
        	print("Yes")
        else:
            if anslist[pointer][1]==anslist[pointer][2]==anslist[pointer][3] and anslist[pointer][0]!=-1:
                print("Yes")
            else:
                print("No")
        pointer+=1
0