結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 10:16:16 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,710 bytes |
| 記録 | |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 20,648 KB |
| 実行使用メモリ | 105,692 KB |
| 最終ジャッジ日時 | 2026-04-18 10:17:21 |
| 合計ジャッジ時間 | 16,707 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 12 -- * 18 |
ソースコード
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