結果
| 問題 | No.592 括弧の対応 (2) |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-28 22:58:42 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 5,000 ms |
| コード長 | 423 bytes |
| 記録 | |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 20,572 KB |
| 実行使用メモリ | 28,336 KB |
| 最終ジャッジ日時 | 2026-04-04 20:40:57 |
| 合計ジャッジ時間 | 1,724 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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