結果

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

ソースコード

diff #

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

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