結果

問題 No.592 括弧の対応 (2)
ユーザー ysys
提出日時 2018-08-18 05:53:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,375 ms / 5,000 ms
コード長 217 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2024-04-20 22:35:05
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,624 KB
testcase_01 AC 1,428 ms
19,004 KB
testcase_02 AC 2,375 ms
18,964 KB
testcase_03 AC 235 ms
18,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
st = []
rec = [0] * n
for i in range(n):
    if s[i] == "(":
        st.insert(0, i)
    else:
        j = st.pop(0)
        rec[i] = j
        rec[j] = i

for i in rec:
    print(i + 1)

0