結果

問題 No.592 括弧の対応 (2)
ユーザー Yuhel TanakaYuhel Tanaka
提出日時 2018-12-20 13:34:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 309 ms / 5,000 ms
コード長 337 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 35,284 KB
最終ジャッジ日時 2023-10-26 00:53:56
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,012 KB
testcase_01 AC 309 ms
33,096 KB
testcase_02 AC 307 ms
35,284 KB
testcase_03 AC 283 ms
31,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as dd

d=dd(int)
l=[]
n=int(input())

for i,j in enumerate(input(),start=1):
    if not l:
        l.append((i,j))
    else:
        a,b=l[-1]
        if b=="(" and j==")":
            d[a],d[i]=i,a
            l.pop()
        else:
            l.append((i,j))

for i in range(1,n+1):
    print(d[i])
0