結果

問題 No.22 括弧の対応
ユーザー jamadjamad
提出日時 2017-06-16 03:09:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 397 ms / 5,000 ms
コード長 320 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 9,064 KB
最終ジャッジ日時 2023-09-27 13:16:59
合計ジャッジ時間 3,787 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 15 ms
7,932 KB
testcase_03 AC 397 ms
9,064 KB
testcase_04 AC 99 ms
8,632 KB
testcase_05 AC 83 ms
8,544 KB
testcase_06 AC 177 ms
8,996 KB
testcase_07 AC 253 ms
8,924 KB
testcase_08 AC 138 ms
8,900 KB
testcase_09 AC 113 ms
8,708 KB
testcase_10 AC 230 ms
8,892 KB
testcase_11 AC 78 ms
8,552 KB
testcase_12 AC 142 ms
8,772 KB
testcase_13 AC 246 ms
8,964 KB
testcase_14 AC 22 ms
8,340 KB
testcase_15 AC 335 ms
8,996 KB
testcase_16 AC 340 ms
8,972 KB
testcase_17 AC 15 ms
7,808 KB
testcase_18 AC 16 ms
7,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
S=input()
I=[x+1 for x in range(N)]
ANS={}
while 1:
    before=len(S)
    idx=S.find('()')
    T=list(S)
    if not T:break
    T.pop(idx)
    if not T:break
    T.pop(idx)
    S=''.join(T)
    a=I.pop(idx)
    b=I.pop(idx)
    ANS[a]=b
    ANS[b]=a
    if before==len(S):break
print(ANS[K])
0