This page is still under construction.

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

Watering Plants (Large)

Time limit60sMemory limit512 MB

Summary
Given non-overlapping plant disks, find the smallest radius R so that two disks of radius R together cover every plant disk completely.
Level

Hard9 of 10

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

Problem

Your greenhouse holds several plants that need water. Each plant takes up an area which is a circle, and no two plants overlap or touch.

You are going to buy two sprinklers. Each sprinkler sprays water on every point 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 at least one of the two circles the sprinklers water.

The sprinklers are installed on the ceiling, so a sprinkler's position may be inside the area of a plant.

Given the center and the radius of every plant, find the minimum radius RR for which the two sprinklers can be placed so that every plant gets enough water.

Input

The first line contains the number of test cases CC.

Each test case has the following form.

  • One line with the number of plants NN.
  • NN lines, one per plant, each with three integers X Y R, where (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≤X≤10001 \le X \le 1000
  • 1≤Y≤10001 \le Y \le 1000
  • 1≤R≤1001 \le R \le 100
  • 1≤C≤301 \le C \le 30
  • 1≤N≤401 \le N \le 40
  • No two plants overlap or touch.

Output

For each test case, print one line of the form Case #x: R, where xx is the number of the test case starting from 1 and RR is the minimum radius of the sprinklers. Print RR rounded to exactly four digits after the decimal point.

Every answer in the test data is at least 10−510^{-5} away from a rounding boundary. A solution whose error is at most 10−610^{-6} prints the same digits.

Notes

In the first test case of the sample, a sprinkler of radius at least 7 centered at (20,15)(20, 15) waters the first two plants, and a sprinkler of radius 3 waters the plant at (40,10)(40, 10).

In the second test case, one of the two sprinklers needs a radius of at least 8. The plant at (30,10)(30, 10) must also lie completely inside one of the two circles.

Examples3

  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.0000
    Case #2: 8.0000
    Case #3: 26.0000
    Case #4: 8.0711
    Case #5: 51.0000
    
  2. Example 2

    Input
    4
    1
    500 500 100
    2
    1 1 1
    1000 1000 100
    3
    10 10 1
    10 20 1
    10 30 1
    4
    100 100 2
    120 100 2
    100 120 2
    120 120 2
    
    Expected output
    Case #1: 100.0000
    Case #2: 100.0000
    Case #3: 6.0000
    Case #4: 12.0000
    
  3. Example 3

    Input
    2
    5
    100 100 1
    100 120 1
    300 100 1
    300 120 1
    200 110 3
    4
    1 1 1
    1 1000 1
    1000 1 1
    1000 1000 1
    
    Expected output
    Case #1: 52.4902
    Case #2: 500.5000