結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
![]() |
提出日時 | 2017-11-16 14:25:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 176 ms / 5,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 30,256 KB |
最終ジャッジ日時 | 2024-11-25 06:24:07 |
合計ジャッジ時間 | 1,297 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#!/usr/bin/env python import collections def check_brackets(s): n = len(s) res = [-1 for _ in range(n)] stack = collections.deque() for i, c in enumerate(s): if c == '(': stack.append(i) else: j = stack.pop() res[i] = j res[j] = i return res def main(): _ = input() s = input() res = check_brackets(s) print(*(r + 1 for r in res), sep="\n") if __name__ == '__main__': main()