結果

問題 No.592 括弧の対応 (2)
ユーザー ttrttr
提出日時 2020-06-03 19:36:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 201 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 10,532 KB
実行使用メモリ 17,256 KB
最終ジャッジ日時 2023-08-16 19:00:38
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,644 KB
testcase_01 AC 201 ms
16,972 KB
testcase_02 AC 198 ms
17,256 KB
testcase_03 AC 196 ms
16,828 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