結果
問題 | No.592 括弧の対応 (2) |
ユーザー | htkb |
提出日時 | 2017-11-10 22:31:47 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 155 ms / 5,000 ms |
コード長 | 289 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 31,944 KB |
最終ジャッジ日時 | 2024-05-03 12:41:07 |
合計ジャッジ時間 | 1,155 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
10,624 KB |
testcase_01 | AC | 155 ms
31,312 KB |
testcase_02 | AC | 151 ms
31,944 KB |
testcase_03 | AC | 152 ms
31,436 KB |
ソースコード
from collections import deque N = int(input()) s = input() result = [0]*N dq = deque() append, pop = dq.append, dq.pop for i, c in enumerate(s): if c == "(": append(i) else: n = pop() result[n] = i+1 result[i] = n+1 print("\n".join(map(str,result)))