結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 18:09:50 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 447 ms / 2,000 ms |
| コード長 | 692 bytes |
| 記録 | |
| コンパイル時間 | 1,570 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 229,088 KB |
| 最終ジャッジ日時 | 2026-04-18 18:10:20 |
| 合計ジャッジ時間 | 13,561 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
"""
ばかでごめんなさい
"""
from math import isqrt
import sys
mod = 998244353
input = sys.stdin.readline
II = lambda : int(input())
MI = lambda : (int(_) for _ in input().split())
LI = lambda : list(int(_) for _ in input().split())
q = II()
st = [""] * (q + 1)
h = [0] * (q + 1)
op = []
top = 0
for i in range(q):
qry = list(input().split())
if qry[0] == "1":
c = qry[1]
op.append((top, st[top]))
st[top] = c
top += 1
if top >= 3 and st[top-3:top] == ["(", "|", ")"]:
top -= 3
h[len(op)] = top
else:
idx, p = op.pop()
st[idx] = p
top = h[len(op)]
print("Yes" if top == 0 else "No")