CLOPPAIR - Closest Point Pair
You are given N points on a plane and your task is to find a pair of points with the smallest Euclidean distance between them.
All points will be unique and there is only one pair with the smallest distance.
Input
First line of input will contain N (2<=N<=50000) and then N lines follow each line contains two integers giving the X and Y coordinate of the point. Absolute value of X,Y will be at most 10^6.
Output
Output 3 numbers a b c, where a, b (a<b) are the indexes (0 based) of the point pair in the input and c is the distance between them. Round c to 6 decimal digits.
See samples for more clarification.
Input:
5
0 0
0 1
100 45
2 3
9 9
Output:
0 1 1.000000
Input:
5
0 0
-4 1
-7 -2
4 5
1 1
Output:
0 4 1.414214
hide comments
Ben Dean:
2012-11-15 03:16:51
There is not even one correct python submission.
|
|
!(NULL):
2012-05-18 17:50:39
CLOSEST is a similar and more challenging problem. |
|
ramz:
2012-03-26 17:55:17
can you increase the time limit for Ruby. 1s is too less for an input of 50000 entries. |
|
SALVO:
2011-05-28 04:20:25
You can easily write an O(N^2) brute force solution and check for yourself. |
|
Krzysztof Lewko:
2011-05-28 00:08:24
Could i receive some tricky test case, SALVO ?:) |
Added by: | SALVO |
Date: | 2011-04-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Standard Problem |