Chicken Shop Placement
Time limit1sMemory limit128 MB
Find the 3D point that minimizes its distance to the farthest of up to 5000 given planets, and report that distance with its coordinates.
- Level
Medium7 of 10
- Topics
- Geometry
- Solved
- No attempts yet
Problem
In a far away galaxy the chicken delivery chain No Chicken Inc. is opening one new branch. The planets that the new branch will serve are already settled, and the coordinates of all of them have been collected.
Keeping the longest delivery short is what matters, so the branch goes at the position that minimizes the distance to the farthest planet. The branch is a single spaceship, so it can trade while landed on a planet or while floating in open space. Treat every planet as a point with no volume.
Given the number of planets and the three dimensional Cartesian coordinates of each planet, write a program that finds the branch position whose distance to the farthest planet is smallest.
Input
Input is read from standard input. The first line holds the number of test cases ().
The first line of each test case holds the number of planets (). Each of the next lines holds the three dimensional Cartesian coordinates , , of one planet, separated by single spaces. Every coordinate is a real number between and , given with up to four digits after the decimal point.
Output
Write to standard output. Print one line per test case holding four real numbers separated by single spaces. The first number is the distance from the branch to the farthest planet, and the second, third and fourth are the , , coordinates of the branch. Round all four numbers at the fifth decimal place and print four digits after the decimal point.
Only one position minimizes the distance to the farthest planet, so the answer is unique. The input data keeps all four printed numbers far enough from a rounding boundary that the rounded result is never ambiguous.