結果

問題 No.22 括弧の対応
ユーザー bellangeldindonbellangeldindon
提出日時 2017-06-03 13:48:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 6,648 KB
実行使用メモリ 6,556 KB
最終ジャッジ日時 2023-09-27 13:16:14
合計ジャッジ時間 1,309 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,932 KB
testcase_01 AC 10 ms
6,104 KB
testcase_02 AC 9 ms
5,852 KB
testcase_03 AC 14 ms
6,504 KB
testcase_04 AC 11 ms
6,112 KB
testcase_05 AC 11 ms
6,148 KB
testcase_06 AC 13 ms
6,320 KB
testcase_07 AC 13 ms
6,524 KB
testcase_08 AC 14 ms
6,384 KB
testcase_09 AC 11 ms
6,240 KB
testcase_10 AC 13 ms
6,556 KB
testcase_11 AC 11 ms
6,204 KB
testcase_12 AC 12 ms
6,356 KB
testcase_13 AC 13 ms
6,328 KB
testcase_14 AC 10 ms
5,920 KB
testcase_15 AC 13 ms
6,416 KB
testcase_16 AC 13 ms
6,424 KB
testcase_17 AC 9 ms
5,880 KB
testcase_18 AC 9 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inpt = map(int, raw_input().split())
n = inpt[0]
k = inpt[1]
s = raw_input()
ansmemo = []
for i in range(0, n+1):
	ansmemo.append(0)
stack = []

for i in range(0, len(s)):
	if s[i] == '(':
		stack.append(i+1)
	else:
		x = stack.pop(-1)
		ansmemo[i+1] = x
		ansmemo[x] = i+1

print ansmemo[k]
0