結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-27 08:35:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,839 ms / 2,000 ms |
| コード長 | 864 bytes |
| 記録 | |
| コンパイル時間 | 324 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 215,168 KB |
| 最終ジャッジ日時 | 2026-05-27 08:36:09 |
| 合計ジャッジ時間 | 53,191 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
Q = int(input())
A = []
B = []
cnt = 1
for _ in range(Q):
qry = list(input().split())
if qry[0] == '1':
A.append((qry[1],cnt))
cnt += 1
if len(A)>=3 and qry[1]==")" and A[-2][0]=="|" and A[-3][0]=="(":
B.append(A.pop())
B.append(A.pop())
B.append(A.pop())
if len(A)==0:
print("Yes")
else:
print("No")
else:
n1 = -1
if len(A)>0:
n1 = A[-1][1]
n2 = -1
if len(B)>0:
n2 = B[-3][1]
if n1>n2:
A.pop()
if len(A)==0:
print("Yes")
else:
print("No")
else:
A.append(B.pop())
A.append(B.pop())
A.append(B.pop())
A.pop()
print("No")
cnt -= 1