这么魔性的代码不确定是不是自己写的…..
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int a[100005];
struct point
{
double x,y;
}p[100005];
inline double len(point &a , point &b)
{
return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
int xxx(const point &a , const point &b)
{
return a.x < b.x;
}
int yyy(int &a,int &b)
{
return p[a].y < p[b].y;
}
inline double min(double a,double b)
{
return a < b ? a : b;
}
double cl(int low,int high)
{
if(low + 1 == high)
return len(p[low] , p[high]);
if(low + 2 == high)
return min(len(p[low] , p[high]) , min( len(p[low] , p[low+1]) , len(p[low+1] , p[high]) ));
int mid = (low + high)>>1;
double ans = min( cl(low , mid) , cl(mid + 1 , high) );
int i , j , cnt = 0;
for(i = low ; i <= high ; ++i)
{
if(p[i].x >= p[mid].x - ans && p[i].x <= p[mid].x + ans)
a[cnt++] = i;
}
sort(a , a + cnt , yyy);
for(i = 0 ; i < cnt ; ++i)
{
for(j = i+1 ; j < cnt ; ++j)
{
if(p[a[j]].y - p[a[i]].y >= ans)
break;
ans = min(ans , len(p[a[i]] , p[a[j]]));
}
}
return ans;
}
int main()
{
int i,n;
while(cin>>n)
{
if(!n)
break;
for(i = 0 ; i < n ; ++i)
cin>>p[i].x>>p[i].y;
sort(p,p+n,xxx);
printf("%.2lf\n",cl(0,n-1));
}
return 0;
}