結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
YuukunA
|
| 提出日時 | 2026-04-18 14:46:24 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 574 bytes |
| 記録 | |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 83,804 KB |
| 最終ジャッジ日時 | 2026-04-18 14:47:10 |
| 合計ジャッジ時間 | 43,160 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 WA * 8 |
ソースコード
import sys
input = sys.stdin.readline
Q = int(input())
states = [(0, 0, 0, 0)]
for _ in range(Q):
q = input().split()
if q[0] == '1':
x, y, min_x, min_y = states[-1]
c = q[1]
if c == '(':
x += 1
elif c == '|':
x -= 1
y += 1
else:
y -= 1
states.append((x, y, min(min_x, x), min(min_y, y)))
else:
states.pop()
x, y, min_x, min_y = states[-1]
if x == 0 and y == 0 and min_x >= 0 and min_y >= 0:
print("Yes")
else:
print("No")
YuukunA