結果

問題 No.592 括弧の対応 (2)
ユーザー 👑 KazunKazun
提出日時 2020-10-15 19:53:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 223 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 87,036 KB
最終ジャッジ日時 2023-09-28 01:17:35
合計ジャッジ時間 1,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,464 KB
testcase_01 AC 123 ms
86,792 KB
testcase_02 AC 122 ms
86,908 KB
testcase_03 AC 118 ms
87,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

Q=deque([])
A=[0]*N

for i in range(N):
    if S[i]=="(":
        Q.appendleft(i)
    else:
        a=Q.popleft()
        A[a]=i+1
        A[i]=a+1

print(*A,sep="\n")
0