結果

問題 No.22 括弧の対応
ユーザー 👑 H20H20
提出日時 2020-12-08 14:05:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 369 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 64,216 KB
最終ジャッジ日時 2023-10-17 17:12:27
合計ジャッジ時間 2,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,544 KB
testcase_01 AC 41 ms
53,544 KB
testcase_02 AC 41 ms
53,544 KB
testcase_03 AC 49 ms
64,212 KB
testcase_04 AC 47 ms
62,020 KB
testcase_05 AC 48 ms
62,032 KB
testcase_06 AC 49 ms
62,032 KB
testcase_07 AC 48 ms
64,212 KB
testcase_08 AC 46 ms
62,032 KB
testcase_09 AC 47 ms
62,020 KB
testcase_10 AC 47 ms
62,032 KB
testcase_11 AC 47 ms
62,032 KB
testcase_12 AC 51 ms
62,032 KB
testcase_13 AC 50 ms
64,216 KB
testcase_14 AC 46 ms
61,896 KB
testcase_15 AC 49 ms
64,212 KB
testcase_16 AC 48 ms
62,020 KB
testcase_17 AC 40 ms
53,544 KB
testcase_18 AC 40 ms
53,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,K = map(int,input().split())
S = input()
D = collections.deque(list('xx'))
NO = collections.deque()
for i in range(N):
    D.append(S[i])
    NO.append(i+1)
    if D[-2]=='(' and D[-1]==')':
        D.pop()
        D.pop()
        R = NO.pop()
        L = NO.pop()
        if R == K :
            print(L)
        if L == K :
            print(R)

0