結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-04-21 04:52:51 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 544 bytes |
| 記録 | |
| コンパイル時間 | 537 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 27,864 KB |
| 最終ジャッジ日時 | 2026-04-21 04:53:37 |
| 合計ジャッジ時間 | 42,409 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 WA * 10 |
ソースコード
import sys
input = sys.stdin.readline
Q=int(input())
A=[]
X=[]
for tests in range(Q):
L=input().split()
if L[0]=="1":
x=L[1]
A.append(x)
X.append(x)
while len(X)>=3 and X[-1]==")" and X[-2]=="|" and X[-3]=="(":
X.pop()
X.pop()
X.pop()
else:
k=A.pop()
if X and X[-1]==k:
X.pop()
else:
X.append("(")
X.append("|")
if X==[]:
print("Yes")
else:
print("No")
titia