結果

問題 No.592 括弧の対応 (2)
ユーザー ttrttr
提出日時 2020-06-03 19:36:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 237 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 19,652 KB
最終ジャッジ日時 2024-05-04 02:32:01
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,624 KB
testcase_01 AC 237 ms
19,016 KB
testcase_02 AC 223 ms
19,652 KB
testcase_03 AC 227 ms
18,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
S = input()

q = deque()
ans = [0]*N
for i in range(N):
    if S[i] == "(":
        q.append(i)
    else:
        t = q.pop()
        ans[t] = i
        ans[i] = t

for a in ans:
    print(a+1)
0