結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー potato1938
提出日時 2026-04-18 10:17:52
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
RE  
実行時間 -
コード長 1,710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,193 ms
コンパイル使用メモリ 80,256 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2026-04-18 10:18:04
合計ジャッジ時間 6,678 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 30
権限があれば一括ダウンロードができます

ソースコード

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]=="(":
                try:
                    anslist[0]=[0,1,0,0]
                except:
                    anslist.append([0,1,0,0])
            elif query[1]=="|":
                try:
                    anslist[0]=[-1,0,1,0]
                except:
                    anslist.append([-1,0,1,0])
            else:
                try:
                    anslist[0]=[-1,0,0,1]
                except:
                    anslist.append([-1,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<0:
            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