結果
| 問題 | No.592 括弧の対応 (2) |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-28 22:58:42 |
| 言語 | Python3 (3.14.2 + numpy 2.4.0 + scipy 1.16.3) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 5,000 ms |
| コード長 | 423 bytes |
| 記録 | |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 26,592 KB |
| 最終ジャッジ日時 | 2024-09-15 16:26:28 |
| 合計ジャッジ時間 | 1,790 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().rstrip().decode()
stack = [(-1,'$')]
pair = [0] * (N+1)
for i,s in enumerate(S,1):
if s == ')' and stack[-1][1] == '(':
j = stack[-1][0]
pair[i] = j
pair[j] = i
stack.pop()
else:
stack.append((i,s))
print(*pair[1:], sep='\n')
maspy