結果

問題 No.22 括弧の対応
ユーザー H20
提出日時 2020-12-08 14:05:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 369 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,124 KB
実行使用メモリ 64,836 KB
最終ジャッジ日時 2024-09-17 14:37:39
合計ジャッジ時間 1,917 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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