結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 20:29:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 585 bytes |
| 記録 | |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 84,992 KB |
| 実行使用メモリ | 138,684 KB |
| 最終ジャッジ日時 | 2026-04-17 20:30:26 |
| 合計ジャッジ時間 | 41,275 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
Q=int(input())
from collections import deque
q=deque()
for _ in range(Q):
query=list(input().split())
if query[0]=='1':
q.append(query[1])
while len(q)>=3 and q[-3]=='(' and q[-2]=='|' and q[-1]==')':
q.pop()
q.pop()
q.pop()
else:
if q:
q.pop()
else:
q.append('(')
q.append('|')
while len(q)>=3 and q[-3]=='(' and q[-2]=='|' and q[-1]==')':
q.pop()
q.pop()
q.pop()
if q:
print("No")
else:
print("Yes")