結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 16:05:54 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 740 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 86,400 KB |
| 最終ジャッジ日時 | 2026-09-09 16:18:51 |
| 合計ジャッジ時間 | 14,151 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 2 -- * 28 |
ソースコード
N = int(input())
S = ""
result = []
num1 = 0
num2 = 0
num3 = 0
last = ""
def judge(st):
if st == "":
return "Yes"
return "No" if st == st.replace("(|)", "") else judge(st.replace("(|)", ""))
querys = [input().split() for _ in range(N)]
for query in querys:
if query[0] == "1":
c = query[-1]
last = c
S += c
match c:
case ("("):
num1 += 1
case (")"):
num2 += 1
case ("|"):
num3 += 1
else:
S = S[:-1]
match last:
case ("("):
num1 -= 1
case (")"):
num2 -= 1
case ("|"):
num3 -= 1
print(judge(S))