結果

問題 No.592 括弧の対応 (2)
ユーザー mokraimokrai
提出日時 2017-12-03 18:22:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 155 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 10,676 KB
実行使用メモリ 31,512 KB
最終ジャッジ日時 2023-08-19 01:59:15
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,768 KB
testcase_01 AC 152 ms
31,496 KB
testcase_02 AC 152 ms
31,512 KB
testcase_03 AC 155 ms
30,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    S = input()

    d = {}
    left_paren = []
    for i, e in enumerate(list(S)):
        if e == '(':
            left_paren.append(i)
        else:
            index = left_paren.pop()
            d[index] = i
            d[i] = index

    for i in range(N):
        print(d[i] + 1)


if __name__ == '__main__':
    main()
0