#P1378. Maximizing the Total Area of Expanding Oil Drops

    ID: 14665 Type: Default 1000ms 256MiB

Maximizing the Total Area of Expanding Oil Drops

Maximizing the Total Area of Expanding Oil Drops

Given a rectangular frame with width W and height H, and at most N distinct points placed strictly inside it, you are to determine the order in which to place oil drops such that the total area covered by the drops is maximized.

When an oil drop is placed at a chosen point, imagine a very small droplet of oil is deposited. It then expands in the shape of a circle until it touches the boundary of the frame or any previously placed oil drop (note that drops do not merge). The expansion of one drop must finish before the next drop is placed. The area of a circle is given by \(S = \pi r^2\), where \(r\) is the radius of the circle.

Your task is to output the maximum possible total area covered by the oil drops (i.e. the sum of the areas of all the circles) as well as one order of placements (represented as a permutation of the point indices, starting from 1) that achieves this maximum.

inputFormat

The input contains the following:

  • The first line contains two numbers \(W\) and \(H\), the width and height of the rectangular frame.
  • The second line contains an integer \(N\) denoting the number of points.
  • Each of the following \(N\) lines contains two real numbers \(x\) and \(y\) representing the coordinates of one point. It is guaranteed that \(0 < x < W\) and \(0 < y < H\).

outputFormat

The output should consist of two lines:

  1. The first line contains a floating-point number, representing the maximum total area covered by the oil drops. Answers with an absolute or relative error of at most \(10^{-6}\) will be accepted.
  2. The second line contains a permutation of \(N\) integers (1-indexed), representing an order of placing the oil drops that achieves the maximum total area. If there are multiple optimal orders, output any one of them.

sample

10 10
1
5 5
78.53981633974483

1

</p>