結果

問題 No.592 括弧の対応 (2)
ユーザー ttr
提出日時 2020-06-03 19:36:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 225 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 19,396 KB
最終ジャッジ日時 2024-11-25 08:40:54
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

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