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

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

hide comments
2016-12-17 15:54:49
can anyone provide me fully accepted code for this question ,, i am trying it from two days but always getting wa near test case 12 ....
2016-03-23 09:39:42 anshal dwivedi
Use long long int: ) , using double caused me 4 WA on test case 12 ;(
2016-01-19 21:48:24
12th case WA is probably because of the (a<b) condition
2016-01-07 15:07:09 Sudharsansai
Don't use long long...May get WA becoz of that.Use double.Comparisons are not that strict !! Attention to (a<b) in output .( WA becoz of that -_-) .
Can use SPOJ TOOLKIT to get test cases. But some solutions there, are wrong ( Verified using my Brute Force checker) . But those solutions are accepted here. Wish to know whether the test cases here are weak ??


Last edit: 2016-01-07 15:07:37
2015-07-30 16:40:09 shef
Did anyone identify what are we getting WA on 12th case even after using long long int
2015-07-02 17:33:04 TP
Getting WA did n't understand why this is happening ? Only after the 12th case it shows wrong answer?

Last edit: 2015-07-02 21:37:44
2015-06-23 07:41:17 Dewang Sultania
getting WA12 even after using long long int can any1 pls find the mistake
<snip>

Last edit: 2022-07-26 21:52:34
2015-06-22 07:41:25 sHaShAnK sHeKhAr
Use long long int :)
2015-05-24 17:23:43 Rishab Banerjee
12th test case WA no idea why :-( I have used line-sweep algorithm

Last edit: 2015-05-24 17:24:32
2015-03-16 16:54:01 Kamil Debowski
guys, be careful about "Round c to 6 decimal digits."
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.