Lowest Latency
Time limit8sMemory limit1024 MB
Given 10^5 random 3D integer points, find the minimum Euclidean distance between any pair of them.
- Level
Medium6 of 10
- Topics
- Divide and conquer, Sorting, Geometry
- Solved
- No attempts yet
Problem
It is the year 2222. The whole universe has been explored, and settlements have been built on every single planet. You live in one of these settlements.
Life is comfortable in almost every way, but there is one serious problem. The latency of the internet connection with other planets is far too high.
The fix is to lay Bonded, Astronomically Paired Cables between all planets, and the internet would become very fast. Building a cable between two planets is harder than it sounds, so the first prototype will connect the two planets that are closest to each other.
The universe is modeled as a large cube measuring lightyears in each dimension. There are stationary planets. All coordinates are independent uniformly random integers from to .
Given the planet positions, find the minimal Euclidean distance between any two planets.
Input
The first line contains an integer , the number of planets. Each of the next lines contains three integers , , and (), the coordinates of one planet.
Every submission is run on exactly 100 test cases, and each has . The samples are smaller and only illustrate the format. Each run uses newly generated random test cases.
Output
Print the minimal Euclidean distance between any two planets. An absolute or relative error of at most is accepted.