結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 00:17:29 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 252 ms |
| コンパイル使用メモリ | 85,888 KB |
| 実行使用メモリ | 190,236 KB |
| 最終ジャッジ日時 | 2026-04-18 00:18:20 |
| 合計ジャッジ時間 | 39,797 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 WA * 11 |
ソースコード
pre=-1
cur=0
Q=int(input())
from collections import deque
q=deque()
dame=deque()
cur=[0]
for _ in range(Q):
query=list(input().split())
if query[0]=='1':
c=query[1]
q.append(c)
if c=='(':
cur.append(cur[-1]+1)
elif c=='|':
cur.append(cur[-1])
else:
cur.append(cur[-1]-1)
if len(cur)<=3 or cur[-3]==cur[-1]:
dame.append(len(cur))
elif cur[-1]<0:
dame.append(len(cur))
else:
c=q.pop()
cur.pop()
while len(dame)>0 and dame[-1]>=len(cur):
dame.pop()
if len(dame)==0 and cur[-1]==0:
print("Yes")
else:
print("No")