結果
| 問題 | No.3503 Brackets Stack Query 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-16 18:33:16 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
TLE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 682 bytes |
| 記録 | |
| コンパイル時間 | 94 ms |
| コンパイル使用メモリ | 64,836 KB |
| 実行使用メモリ | 182,240 KB |
| 最終ジャッジ日時 | 2026-10-17 03:47:09 |
| 合計ジャッジ時間 | 80,544 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 30 |
ソースコード
#https://yukicoder.me/submissions/1160875 写経
Q = int(input())
A = []
X = []
D = {}
for i in range(Q):
q = input().split()
if q[0] == '1':
x = q[1]
A.append(x)
X.append((x, len(A) - 1))
if len(X) >= 3 and X[-1][0] == ')' and X[-2][0] == '|' and X[-3][0] == '(':
a = X.pop()
b = X.pop()
c = X.pop()
D[a[1]] = (b, c)
else:
k = A.pop()
if X and X[-1][0] == k and X[-1][1] == len(A): # 復元不要
X.pop()
else:
X.append(D[len(A)][1])
X.append(D[len(A)][0])
if X == []:
print('Yes')
else:
print('No')