結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー norioc
提出日時 2026-10-18 01:28:44
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 646 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,940 KB
実行使用メモリ 122,920 KB
最終ジャッジ日時 2026-10-18 01:30:04
合計ジャッジ時間 76,700 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 1 TLE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

Q = int(input())

st = []
st2 = []
for _ in range(Q):
    qs = input().split()

    match qs:
        case ('1', c):
            if c == ')':
                if len(st) >= 2 and st[-2] == '(' and st[-1] == '|':
                    st.append(c)
                    st2.append(True)
                else:
                    st.append(c)
                    st2.append(False)
            else:
                st.append(c)
                st2.append(False)

        case ('2',):
            st.pop()
            st2.pop()

        case _:
            assert False

    if len(st) == 0 or st2[-1]:
        print('Yes')
    else:
        print('No')
0