結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 16:55:03 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 839 bytes |
| 記録 | |
| コンパイル時間 | 514 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 102,620 KB |
| 最終ジャッジ日時 | 2026-04-19 16:56:41 |
| 合計ジャッジ時間 | 23,799 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | RE * 9 TLE * 3 -- * 18 |
ソースコード
N = int(input())
S = ""
result = []
num1 = 0
num2 = 0
num3 = 0
last = ""
def judge(st):
if not num1 == num2 or not num2 == num3:
return "No"
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
last = S[-1]
print(judge(S))