結果

問題 No.22 括弧の対応
ユーザー liny_tailliny_tail
提出日時 2020-08-12 09:53:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,636 KB
実行使用メモリ 9,436 KB
最終ジャッジ日時 2023-09-27 13:49:22
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,096 KB
testcase_01 AC 13 ms
8,148 KB
testcase_02 AC 13 ms
8,088 KB
testcase_03 AC 20 ms
9,436 KB
testcase_04 AC 17 ms
8,744 KB
testcase_05 AC 18 ms
8,764 KB
testcase_06 AC 20 ms
9,052 KB
testcase_07 AC 18 ms
9,056 KB
testcase_08 AC 17 ms
8,864 KB
testcase_09 AC 18 ms
8,832 KB
testcase_10 AC 18 ms
9,200 KB
testcase_11 AC 17 ms
8,588 KB
testcase_12 AC 18 ms
8,792 KB
testcase_13 AC 22 ms
9,072 KB
testcase_14 AC 14 ms
8,216 KB
testcase_15 AC 19 ms
9,336 KB
testcase_16 AC 21 ms
9,300 KB
testcase_17 AC 13 ms
8,096 KB
testcase_18 AC 14 ms
8,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = [int(i) for i in input().strip().split(' ')]
S = [[i, n] for n, i in enumerate(list(input().strip()))]

p = 0
while True:
  if S[p][0] + S[p + 1][0] == '()':
    if K - 1 in [S[p][1], S[p + 1][1]]:
      print([S[p + 1][1], S[p][1]][[S[p][1], S[p + 1][1]].index(K - 1)] + 1)
      exit(0)
    
    del S[p:p+2]
    p -= 1
  else:
    p += 1
0