結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-10-18 02:41:13 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 281 ms / 2,000 ms |
| + 887µs | |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 77 ms |
| コンパイル使用メモリ | 64,456 KB |
| 実行使用メモリ | 116,048 KB |
| 最終ジャッジ日時 | 2026-10-18 02:41:32 |
| 合計ジャッジ時間 | 12,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
import sys
input = sys.stdin.readline
Q = int(input())
st = []
st2 = []
for _ in range(Q):
qs = input().split()
match qs:
case ('1', ')'):
if len(st) >= 2 and st[-2] == '(' and st[-1] == '|':
st.pop()
st.pop()
st2.append(True)
else:
st.append(')')
st2.append(False)
case ('1', C):
st.append(C)
st2.append(False)
case ('2',):
if st2.pop():
st.append('(')
st.append('|')
else:
st.pop()
case _:
assert False
if len(st) == 0:
print('Yes')
else:
print('No')
norioc