Under construction

Still being built. Things may change

Lowest Latency

Time limit8sMemory limit1024 MB

Summary
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 10910^9 lightyears in each dimension. There are 10510^5 stationary planets. All coordinates are independent uniformly random integers from 00 to 10910^9.

Given the planet positions, find the minimal Euclidean distance between any two planets.

Input

The first line contains an integer nn, the number of planets. Each of the next nn lines contains three integers xx, yy, and zz (0≤x,y,z<1090 \le x, y, z < 10^9), the coordinates of one planet.

Every submission is run on exactly 100 test cases, and each has n=105n = 10^5. 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 10−610^{-6} is accepted.

Examples2

  1. Example 1

    Input
    5
    10 5 1
    8 2 0
    4 7 5
    1 0 9
    0 10 7
    
    Expected output
    3.7416573867739413
    
  2. Example 2

    Input
    3
    790726336 656087587 188785845
    976472310 22830435 160538063
    211966015 87530388 542618498
    
    Expected output
    660540781.9387681