結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 09:06:30 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,371 bytes |
| 記録 | |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 81,280 KB |
| 実行使用メモリ | 212,380 KB |
| 最終ジャッジ日時 | 2026-09-08 10:05:42 |
| 合計ジャッジ時間 | 42,851 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 10 |
ソースコード
import copy
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]=copy.copy(mae)
except:
anslist.append(copy.copy(mae))
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]:
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