This page is still under construction.

Parts of this page are still being built. What you see may change.

Secrets in Shadows

Time limit1sMemory limit128 MB

Summary
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 11 (diameter 22), so the shadow cast by a single column is an infinitely long strip whose width equals the diameter, 22. 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 θ\theta. East is θ=0\theta = 0, south is θ=π/2\theta = \pi/2, and west is θ=π\theta = \pi; the sun rises in the east (θ=0\theta = 0) and sets in the west (θ=π\theta = \pi). The xx-axis points east and the yy-axis points north, and the center of each column's base disk is given by its (x,y)(x, y) coordinates.

Fig. F-5: Definition of the sun-direction angle θ\theta

As θ\theta ranges over [0,π)[0, \pi), the width of the whole shadow takes different values. Your task is to compute the minimum width Wmin⁡W_{\min} and the maximum width Wmax⁡W_{\max} 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
  • nn is the number of columns, a positive integer with 1≤n≤1001 \le n \le 100.
  • xkx_k and yky_k are the coordinates of the center of the kk-th column's base disk. They are positive integers with 1≤xk,yk≤301 \le x_k, y_k \le 30, separated by a space.

Each base disk has radius 11 (diameter 22). Columns may touch but never overlap, so the distance between any two centers is at least 22.

Output

For each dataset, print two lines with no extra characters (such as trailing spaces):

  • the first line is the minimum width Wmin⁡W_{\min} of the whole shadow,
  • the second line is the maximum width Wmax⁡W_{\max} of the whole shadow.

Print each width rounded to exactly 44 digits after the decimal point.

Examples4

  1. Example 1

    Input
    3
    1 1
    3 1
    4 3
    4
    1 1
    2 3
    3 8
    1 9
    8
    1 1
    3 1
    6 1
    1 3
    5 3
    1 7
    3 5
    5 5
    8
    20 7
    1 27
    30 14
    9 6
    17 13
    4 2
    17 7
    8 9
    0
    
    Expected output
    3.1094
    5.6056
    4.0000
    7.1623
    6.8507
    9.3301
    9.5155
    15.6056
    
  2. Example 2

    Input
    1
    15 15
    0
    
    Expected output
    2.0000
    2.0000
    
  3. Example 3

    Input
    2
    1 1
    5 1
    0
    
    Expected output
    2.0000
    4.0000
    
  4. Example 4

    Input
    7
    1 1
    6 2
    11 1
    3 6
    9 7
    2 11
    10 12
    0
    
    Expected output
    7.8605
    12.9412