結果

問題 No.22 括弧の対応
ユーザー first_vilfirst_vil
提出日時 2021-11-11 22:45:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 225 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,600 KB
実行使用メモリ 8,952 KB
最終ジャッジ日時 2023-08-15 13:36:57
合計ジャッジ時間 1,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,600 KB
testcase_01 AC 18 ms
8,464 KB
testcase_02 AC 18 ms
8,648 KB
testcase_03 AC 21 ms
8,904 KB
testcase_04 AC 20 ms
8,792 KB
testcase_05 AC 19 ms
8,676 KB
testcase_06 AC 20 ms
8,684 KB
testcase_07 AC 20 ms
8,772 KB
testcase_08 AC 20 ms
8,864 KB
testcase_09 AC 19 ms
8,712 KB
testcase_10 AC 20 ms
8,804 KB
testcase_11 AC 20 ms
8,612 KB
testcase_12 AC 20 ms
8,820 KB
testcase_13 AC 21 ms
8,952 KB
testcase_14 AC 19 ms
8,488 KB
testcase_15 AC 21 ms
8,928 KB
testcase_16 AC 21 ms
8,908 KB
testcase_17 AC 18 ms
8,604 KB
testcase_18 AC 18 ms
8,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,k = map(int,input().split())
s = input()
p = [-1] * n
st = deque([])
for i in range(n):
  if s[i] == '(':
    st.append(i)
  else:
    j = st.pop()
    p[i] = j
    p[j] = i
print(p[k - 1] + 1)
0