結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 11:16:40 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 467 bytes |
| 記録 | |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 85,292 KB |
| 実行使用メモリ | 93,212 KB |
| 最終ジャッジ日時 | 2026-04-19 11:18:01 |
| 合計ジャッジ時間 | 18,434 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 2 WA * 9 TLE * 1 -- * 18 |
ソースコード
S = ""
c = 0
b = 0
for i in range(int(input())):
q = input()
if q.startswith("1"):
S += q[2]
if q[2] == "(":
c += 1
elif q[2] == ")":
c -= 1
if c < 0:
b = len(S)
else:
if S[-1] == "(":
c -= 1
elif S[-1] == ")":
c += 1
if len(S)-1 < b:
b = 0
S = S[:-1]
print("Yes" if c == 0 and not b and S.count("(") == S.count("|") and "()" not in S and "||" not in S else "No")