結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 10:10:49 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 578 bytes |
| 記録 | |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 247,896 KB |
| 最終ジャッジ日時 | 2026-04-19 10:13:56 |
| 合計ジャッジ時間 | 9,154 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | WA * 11 TLE * 1 -- * 18 |
ソースコード
with open("/dev/stdin","r") as f:
stdin = f.read()
S = ""
c = 0
b = 0
for q in stdin.split("\n")[1:]:
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 "()" not in S and ")(" not in S and c == 0 and not b and "||" not in S and not S.endswith("|") and not S.startswith("|") and S.count("|") == S.count("(") else "No")