結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー moon17
提出日時 2026-04-17 23:41:21
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 515 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 374 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 216,192 KB
最終ジャッジ日時 2026-04-17 23:42:20
合計ジャッジ時間 51,474 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21 WA * 6 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

q=int(input())
p=k1=k2=ng=0
ngq=[]
t=[]
for _ in range(q):
  k,*c=input().split()
  if k=='1':
    c=c[0]
    t.append(c)
    p+=1
    if c=='(':
      k1+=1
    if c=='|':
      k2+=1
    k3=p-k1-k2
    if k1<k3 or k1<k2 or k2<k3 or t[-2:]==[*'||']:
      ng+=1
      ngq.append(1)
    else:
      ngq.append(0)
  else:
    p-=1
    c=t.pop()
    if c=='(':
      k1-=1
    if c=='|':
      k2-=1
    ng-=ngq.pop()
  if k1==k2==p-(k1+k2) and ng<1:
    print('Yes')
  else:
    print('No')
  # print(ngq,''.join(t))
0