This page is still under construction.

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

Watering Plants

Time limit5sMemory limit512 MB

Summary
Given N disjoint disks, find the smallest radius R such that two disks of radius R can cover all the plants.
Level

Hard8 of 10

Topics
Geometry, Binary search, Brute force, Math
Solved
No attempts yet

Problem

Your greenhouse holds several potted plants that need water. The area a plant takes up is a circle, and no two plants overlap or touch each other.

You are going to buy two sprinklers. Each sprinkler waters everything inside a circle of radius RR.

One sprinkler runs in the morning and the other runs at night. A plant gets enough water only if its whole area is watered in the morning, or its whole area is watered at night. So the circle of each plant must lie completely inside one of the two circles the sprinklers water.

The position and radius of every plant are given. Find the minimum radius RR for which the two sprinklers can be placed so that every plant is watered. The sprinklers are installed on the ceiling, so a sprinkler may sit inside the area of a plant.

Input

The first line contains the number of test cases CC.

Each test case is given as follows.

  • The first line contains the number of plants NN.
  • Each of the next NN lines contains three integers XX, YY, RR. (X,Y)(X, Y) is the center of the plant and RR is its radius.

Limits

  • Every number in the input is an integer.
  • 1≤C≤101 \le C \le 10
  • 1≤N≤201 \le N \le 20
  • 1≤X≤10001 \le X \le 1000
  • 1≤Y≤10001 \le Y \le 1000
  • 1≤R≤1001 \le R \le 100
  • No two plants overlap or touch each other.

Output

For each test case, print one line of the form Case #x: R, where xx is the test case number starting from 1 and RR is the minimum sprinkler radius.

Print the radius rounded to six digits after the decimal point. When the minimum radius is 7, print 7.000000.

Notes

In the first case of the example, a sprinkler of radius 7 or more centered at (20, 15) waters the first two plants. The plant at (40, 10) is covered by a radius of 3 or more.

In the second case, one of the two sprinklers needs a radius of 8 or more. The plant at (30, 10) also has to be covered completely by one of the two sprinklers.

Examples2

  1. Example 1

    Input
    5
    3
    20 10 2
    20 20 2
    40 10 3
    3
    20 10 3
    30 10 3
    40 10 3
    5
    100 100 1
    140 100 1
    100 130 1
    100 500 1
    150 500 1
    8
    100 100 1
    110 100 1
    100 110 1
    110 110 1
    200 200 1
    210 200 1
    200 210 1
    210 210 1
    4
    100 100 1
    200 100 1
    200 103 1
    300 103 1
    
    Expected output
    Case #1: 7.000000
    Case #2: 8.000000
    Case #3: 26.000000
    Case #4: 8.071068
    Case #5: 51.000000
    
  2. Example 2

    Input
    1
    1
    1 1 1
    
    Expected output
    Case #1: 1.000000