Secrets in Shadows
Time limit1sMemory limit128 MB
Given unit-disk column centers, find the minimum and maximum total width of their infinite shadow strips as the sun direction varies from east to west.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Binary search
- Solved
- No attempts yet
Problem
Long ago, several identical columns (cylinders) stood upright in a large open field. During the day, as the sun moved across the sky, the shadows of the columns swept across the ground. Each column is so tall that its shadow is effectively infinitely long. Everything is viewed from directly above (a top view).

Fig. F-1: The columns (cylinders)

Fig. F-2: Top view of the columns and their shadows
Every column has the same base disk of radius (diameter ), so the shadow cast by a single column is an infinitely long strip whose width equals the diameter, . The width of the whole shadow is the total width of the union of all the individual shadow strips, measured perpendicular to the sun's rays. Because some strips may overlap, this total width changes as the direction of the sun changes.

Fig. F-3: A sun direction that makes the whole shadow narrow
When the whole shadow splits into several disconnected parts, its width is defined as the sum of the widths of those parts.

Fig. F-4: A sun direction that makes the whole shadow wide
The direction of the sun is described by an angle . East is , south is , and west is ; the sun rises in the east () and sets in the west (). The -axis points east and the -axis points north, and the center of each column's base disk is given by its coordinates.

Fig. F-5: Definition of the sun-direction angle
As ranges over , the width of the whole shadow takes different values. Your task is to compute the minimum width and the maximum width of the whole shadow over all sun directions. The field is a flat plane.
Input
The input contains several datasets and ends with a line containing a single 0.
Each dataset has the form:
n
x1 y1
x2 y2
...
xn yn
- is the number of columns, a positive integer with .
- and are the coordinates of the center of the -th column's base disk. They are positive integers with , separated by a space.
Each base disk has radius (diameter ). Columns may touch but never overlap, so the distance between any two centers is at least .
Output
For each dataset, print two lines with no extra characters (such as trailing spaces):
- the first line is the minimum width of the whole shadow,
- the second line is the maximum width of the whole shadow.
Print each width rounded to exactly digits after the decimal point.