結果

問題 No.22 括弧の対応
ユーザー liny_tail
提出日時 2020-08-12 09:53:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 348 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-07-20 07:51:17
合計ジャッジ時間 1,281 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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