Link:http://acm.split.hdu.edu.cn/showproblem.php?pid=1007
#include <bits/stdc++.h>
using namespace std;
/*
hdu 1007
题意:给出物品在平面上的点坐标,求一个环不能一次套到两的最大半径,即最近点对距离的一半。
题解:先以x排序,用分治将问题分成左边部分的最近点对,和左边的最近点对,左边右边各一个点的
最近点对(在算这个的时候应按y排序,将两点y差大于当前最小值的优化掉)。
*/
const int N = 1e5+5;
const double INF = 1e18;
struct Point{double x,y; } a[N];
bool cmp(Point a,Point b){return a.x < b.x; }
bool cmp2(Point a,Point b){return a.y < b.y; }
double dist(Point a,Point b){return sqrt((a.y-b.y)*(a.y-b.y)+(a.x-b.x)*(a.x-b.x))/2; }
Point temp[N];
double solve(int l, int r){
if(l == r)
return INF;
int mid = (l+r)>>1;
double mi;
mi = solve(l,mid);
mi = min(mi,solve(mid+1,r));
// printf("L=%f R=%f\n",solve(l,mid),solve(mid+1,r));
int top = 0;
temp[top++] = a[mid];
for(int i = mid-1; i >= l; i--){
if(a[mid].x-a[i].x>=mi)
break;
temp[top++] = a[i];
}
for(int i = mid+1; i <= r; i++){
if(a[i].x-a[mid].x>=mi)
break;
temp[top++] = a[i];
}
sort(temp,temp+top,cmp2);
for(int i = 0; i < top; i++){
for(int j = i+1; j < top; j++)
{
if(temp[j].y-temp[i].y>=mi)
break;
mi = min(mi,dist(temp[i],temp[j]));
}
}
return mi;
}
int main()
{
int n;
while(~scanf("%d",&n) && n)
{
for(int i = 0; i < n; i++)
scanf("%lf%lf",&a[i].x,&a[i].y);
sort(a,a+n,cmp);
printf("%.2f\n",solve(0,n-1));
}
return 0;
}