結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 10:35:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
OLE
|
| 実行時間 | - |
| コード長 | 601 bytes |
| 記録 | |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 122,724 KB |
| 最終ジャッジ日時 | 2026-04-19 10:55:55 |
| 合計ジャッジ時間 | 14,964 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | OLE * 2 -- * 28 |
ソースコード
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 c == 0 and not b and "||" not in S and not S.endswith("|") and not S.startswith("|") and S.count("|") == S.count("(") and ")|)" not in S and "(|(" not in S else "No", S)