結果

問題 No.22 括弧の対応
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-12-31 10:03:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 256 bytes
コンパイル時間 1,771 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 60,288 KB
最終ジャッジ日時 2024-04-16 20:47:57
合計ジャッジ時間 4,010 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 37 ms
51,968 KB
testcase_02 AC 38 ms
52,096 KB
testcase_03 AC 44 ms
60,288 KB
testcase_04 AC 45 ms
59,776 KB
testcase_05 AC 44 ms
59,904 KB
testcase_06 AC 44 ms
59,776 KB
testcase_07 AC 44 ms
59,904 KB
testcase_08 AC 43 ms
59,520 KB
testcase_09 AC 43 ms
59,264 KB
testcase_10 AC 43 ms
60,032 KB
testcase_11 AC 43 ms
59,136 KB
testcase_12 AC 44 ms
59,648 KB
testcase_13 AC 44 ms
59,648 KB
testcase_14 AC 41 ms
57,856 KB
testcase_15 AC 44 ms
60,160 KB
testcase_16 AC 43 ms
59,648 KB
testcase_17 AC 37 ms
52,224 KB
testcase_18 AC 37 ms
51,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
par = [-1]*n
S = list(input())

l = []
for i,s in enumerate(S):
    if s == "(":
        l.append([s,i])
        continue
    if l[-1][0] == "(":
        _,p = l.pop()
        par[p] = i
        par[i] = p
print(par[k-1]+1) 
0