結果

問題 No.22 括弧の対応
ユーザー akihito0000akihito0000
提出日時 2016-08-14 08:29:32
言語 Python2
(2.7.18)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 6,496 KB
実行使用メモリ 6,428 KB
最終ジャッジ日時 2023-09-27 13:07:40
合計ジャッジ時間 1,371 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,112 KB
testcase_01 AC 12 ms
5,968 KB
testcase_02 AC 12 ms
5,992 KB
testcase_03 AC 14 ms
6,136 KB
testcase_04 AC 12 ms
5,980 KB
testcase_05 AC 12 ms
6,144 KB
testcase_06 AC 14 ms
6,268 KB
testcase_07 AC 12 ms
5,984 KB
testcase_08 AC 11 ms
5,996 KB
testcase_09 AC 14 ms
6,208 KB
testcase_10 AC 12 ms
6,040 KB
testcase_11 AC 13 ms
6,080 KB
testcase_12 AC 13 ms
6,268 KB
testcase_13 AC 16 ms
6,428 KB
testcase_14 AC 11 ms
6,092 KB
testcase_15 AC 13 ms
6,192 KB
testcase_16 AC 14 ms
6,236 KB
testcase_17 AC 11 ms
6,072 KB
testcase_18 AC 11 ms
5,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
# -*- coding: utf-8 -*-

### INPUT ###
N , h = map(int, raw_input().split())
arrays = raw_input()
num = []
tmp = ""
ans = {}
for i,array in enumerate(arrays):
       	if array == "(":
       		num.append(i+1)
       	if array == ")":
       		tmp = num.pop(-1)
       		ans.update({i+1 : tmp})
       		ans.update({tmp : i+1})
       	if h in ans:
       		print ans[h]
       		exit()
0