結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-18 00:56:19 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 391 ms / 2,000 ms |
| + 558µs | |
| コード長 | 663 bytes |
| 記録 | |
| コンパイル時間 | 305 ms |
| コンパイル使用メモリ | 96,100 KB |
| 実行使用メモリ | 282,168 KB |
| 最終ジャッジ日時 | 2026-08-18 00:56:43 |
| 合計ジャッジ時間 | 15,914 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
from sys import stdin
input = stdin.readline
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
stack = []
stack2 = []
for q in query:
if q[0] == "1":
c = q[1]
if c != ")":
stack.append(c)
stack2.append(0)
elif 2 <= len(stack) and stack[-2:] == ["(", "|"]:
for _ in range(2):
stack.pop()
stack2.append(1)
else:
stack.append(c)
stack2.append(0)
else:
if stack2.pop() == 1:
stack.append("(")
stack.append("|")
else:
stack.pop()
print("Yes" if not stack else "No")
detteiuu