結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-18 00:53:37 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 625 bytes |
| 記録 | |
| コンパイル時間 | 250 ms |
| コンパイル使用メモリ | 95,584 KB |
| 実行使用メモリ | 282,196 KB |
| 最終ジャッジ日時 | 2026-08-18 00:54:21 |
| 合計ジャッジ時間 | 15,582 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 24 |
ソースコード
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("|")
print("Yes" if not stack else "No")
detteiuu