Watering Plants (Large)
Time limit60sMemory limit512 MB
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 . 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 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 .
Each test case has the following form.
- One line with the number of plants .
- lines, one per plant, each with three integers
X Y R, where is the center of the plant and is its radius.
Limits
- Every number in the input is an integer.
- No two plants overlap or touch.
Output
For each test case, print one line of the form Case #x: R, where is the number of the test case starting from 1 and is the minimum radius of the sprinklers. Print rounded to exactly four digits after the decimal point.
Every answer in the test data is at least away from a rounding boundary. A solution whose error is at most prints the same digits.
Notes
In the first test case of the sample, a sprinkler of radius at least 7 centered at waters the first two plants, and a sprinkler of radius 3 waters the plant at .
In the second test case, one of the two sprinklers needs a radius of at least 8. The plant at must also lie completely inside one of the two circles.