結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 23:47:16 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,407 bytes |
| 記録 | |
| コンパイル時間 | 357 ms |
| コンパイル使用メモリ | 20,960 KB |
| 実行使用メモリ | 15,320 KB |
| 最終ジャッジ日時 | 2026-04-17 23:48:06 |
| 合計ジャッジ時間 | 9,187 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 7 -- * 23 |
ソースコード
query_count = int(input())
parent = [0]
state = [-1]
top_history = [0]
broken_history = [False]
for _ in range(query_count):
command = input().split()
if command[0] == '1':
ch = command[1]
current_top = top_history[-1]
is_broken = broken_history[-1]
if is_broken:
top_history.append(current_top)
broken_history.append(True)
elif ch == '(':
parent.append(current_top)
state.append(0)
top_history.append(len(state) - 1)
broken_history.append(False)
elif ch == '|':
if current_top == 0 or state[current_top] == 1:
top_history.append(current_top)
broken_history.append(True)
else:
parent.append(parent[current_top])
state.append(1)
top_history.append(len(state) - 1)
broken_history.append(False)
else:
if current_top == 0 or state[current_top] == 0:
top_history.append(current_top)
broken_history.append(True)
else:
top_history.append(parent[current_top])
broken_history.append(False)
else:
top_history.pop()
broken_history.pop()
if not broken_history[-1] and top_history[-1] == 0:
print("Yes")
else:
print("No")