結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 12:41:35 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 353 bytes |
| 記録 | |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 96,800 KB |
| 最終ジャッジ日時 | 2026-04-18 12:42:48 |
| 合計ジャッジ時間 | 19,424 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 2 WA * 9 TLE * 1 -- * 18 |
ソースコード
q=int(input())
def check(s):
q=0
b=0
for c in s:
if c=="(":
q<<=1
b+=1
if c==")":
if q&1==0:
return False
q>>=1
b-=1
if c=="|":
if q&1==1:
return False
q|=1
return q==0 and b==0
ss=""
for _ in range(q):
t=input().split()
if t[0]=="1":
ss+=t[1]
elif t[0]=="2":
ss=ss[:-1]
print("Yes" if check(ss) else "No")