結果
問題 | No.22 括弧の対応 |
ユーザー | Tsubasa |
提出日時 | 2018-02-07 10:12:23 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 103 ms |
コンパイル使用メモリ | 10,824 KB |
実行使用メモリ | 8,288 KB |
最終ジャッジ日時 | 2023-09-27 13:23:43 |
合計ジャッジ時間 | 1,460 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
7,840 KB |
testcase_01 | AC | 15 ms
7,840 KB |
testcase_02 | AC | 15 ms
7,868 KB |
testcase_03 | AC | 16 ms
8,288 KB |
testcase_04 | AC | 16 ms
7,732 KB |
testcase_05 | AC | 16 ms
7,772 KB |
testcase_06 | AC | 16 ms
8,272 KB |
testcase_07 | AC | 16 ms
8,280 KB |
testcase_08 | AC | 16 ms
8,196 KB |
testcase_09 | AC | 16 ms
8,152 KB |
testcase_10 | AC | 16 ms
8,224 KB |
testcase_11 | AC | 16 ms
7,812 KB |
testcase_12 | AC | 17 ms
8,288 KB |
testcase_13 | AC | 16 ms
7,920 KB |
testcase_14 | AC | 16 ms
7,752 KB |
testcase_15 | AC | 16 ms
8,224 KB |
testcase_16 | AC | 16 ms
8,184 KB |
testcase_17 | AC | 16 ms
7,776 KB |
testcase_18 | AC | 15 ms
7,908 KB |
ソースコード
def main(): N, K = [int(_) for _ in input().split()] K -= 1 S = input() depth_list = [] depth = 0 for letter in S: if letter == "(": depth += 1 depth_list.append(depth) else: depth_list.append(depth) depth -= 1 if S[K] == "(": i = K+1 while True: if depth_list[K] == depth_list[i]: print(i+1) return i += 1 else: i = K-1 while True: if depth_list[K] == depth_list[i]: print(i+1) return i -= 1 main()