結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 00:07:32 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 726 bytes |
| 記録 | |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 242,008 KB |
| 最終ジャッジ日時 | 2026-04-18 00:08:29 |
| 合計ジャッジ時間 | 37,979 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
from collections import deque
S=[""]
T=deque()
ind=[0]
Q=int(input())
for _ in range(Q):
q=list(input().split())
if q[0]=="1":
S.append(q[1])
if len(T)==0:
T.append(q[1])
ind.append(ind[-1]+1)
elif q[1]==")" and len(T)>=2 and (T[-2]=="(" and T[-1]=="|"):
T.pop();T.pop()
ind.append(ind[-1]-1)
else:
T.append(q[1])
ind.append(ind[-1])
else:
if ind[-1]==ind[-2]:
T.pop()
else:
pre=ind[-2]
i=-2
while S[i]!="" and ind[i]==pre:
T.appendleft(S[i])
i-=1
S.pop();ind.pop()
print("Yes" if len(T)==0 else "No")