結果

問題 No.592 括弧の対応 (2)
ユーザー daku9640daku9640
提出日時 2017-11-10 22:59:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 257 bytes
コンパイル時間 1,020 ms
コンパイル使用メモリ 10,692 KB
実行使用メモリ 21,156 KB
最終ジャッジ日時 2023-08-16 03:38:52
合計ジャッジ時間 2,086 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,740 KB
testcase_01 AC 142 ms
21,156 KB
testcase_02 AC 140 ms
21,104 KB
testcase_03 AC 143 ms
20,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
ans = [0] * int(readline())
dq = []
for i, s in enumerate(readline().strip()):
    if s == "(":
        dq.append(i)
    else:
        k = dq.pop()
        ans[k] = i + 1
        ans[i] = k + 1
print(*ans, sep="\n")
0