結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 03:22:18 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 557 bytes |
| 記録 | |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 130,936 KB |
| 最終ジャッジ日時 | 2026-04-19 03:23:04 |
| 合計ジャッジ時間 | 10,336 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 S != "" and "||" not in S and not S.endswith("|") and not S.startswith("|") else "No")