結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 21:52:45 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 981 bytes |
| 記録 | |
| コンパイル時間 | 1,055 ms |
| コンパイル使用メモリ | 20,444 KB |
| 実行使用メモリ | 28,284 KB |
| 最終ジャッジ日時 | 2026-04-17 21:53:37 |
| 合計ジャッジ時間 | 14,503 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 5 -- * 25 |
ソースコード
Q = int(input())
stack = [(0, 0)]
for _ in range(Q):
text = input()
if text[0] == "2":
stack.pop()
else:
c = text[-1]
s, v = stack[-1]
ns = -1
nv = -1
if s == -1:
pass
elif s == 0:
if c == "(":
ns = 1
nv = 1
elif s == 1 or s == 3:
if c == "|":
ns = 2
nv = v
elif c == "(" and s == 1:
ns = 1
nv = v * 2
elif s == 2 or s == 4:
if c == ")":
nv = v // 2
if nv == 0:
ns = 99999
elif v % 2 == 0:
ns = 3
else:
ns = 4
elif c == "(" and s == 2:
ns = 1
nv = v * 2 + 1
stack.append((ns, nv))
if stack[-1][0] == 99999:
print("Yes")
else:
print("No")