Minimum transmitter power
Time limit5sMemory limit512 MB
Place a flagship in 3D so the maximum weighted Manhattan distance to N ships is minimized, and report that minimum power rounded to six decimals.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Implementation, Brute force
- Solved
- No attempts yet
Problem
Near the planet Mars, in a faraway galaxy much like our own, the imperial forces and the rebels are fighting. The rebel fleet has ships. Ship sits at the point and carries a receiver of power . The rebels need to send orders from the flagship to every ship, but their budget is tight and they cannot buy a strong transmitter.
If the flagship is placed at , then reaching the ship at whose receiver has power takes a transmitter power of at least
Choose the flagship position that minimizes the transmitter power needed to reach every ship, and report that power. The flagship coordinates do not have to be integers.
Input
The first line contains the number of test cases .
The first line of each test case contains the number of ships . The next lines each contain four integers , , and separated by single spaces. The first three are the coordinates of ship and the last one is the power of its receiver. Two or more ships may share the same coordinates.
Limits
Output
For each test case print one line in the following format.
Case #X: Y
is the number of the test case and is the smallest transmitter power that reaches every ship of the fleet. Round to six digits after the decimal point and print all six digits even when they are zeros. When the discarded part is exactly one half, round up.
Hint
The flagship coordinates need not be integers. If the ships are at , , and and every receiver has power , a flagship at reaches all of them with transmitter power . With a single ship the flagship can sit on top of it, so the answer is .