2 0 0 1 1 2 1 1 1 1 3 -1.5 0 0 0 0 1.5 0
0.71 0.00 0.75
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 100005; 4 const int INF = 0x3f3f3f3f; 5 struct Point{ 6 double x,y; 7 int index; 8 Point(double tx = 0,double ty = 0,int z = 0){ 9 x = tx; 10 y = ty; 11 index = z; 12 } 13 }Bx[maxn],By[maxn],Bz[maxn],tmp[maxn]; 14 bool cmpx(const Point &a,const Point &b){ 15 return a.x < b.x; 16 } 17 bool cmpy(const Point &a,const Point &b){ 18 return a.y < b.y; 19 } 20 double calc(const Point &a,const Point &b){ 21 return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y)); 22 } 23 double closet(int low,int high){ 24 double ret = INF; 25 if(low + 2 >= high){ 26 for(int i = low; i <= high; ++i) 27 for(int j = i + 1; j <= high; ++j) 28 ret = min(ret,calc(Bx[i],Bx[j])); 29 return ret; 30 } 31 int mid = (low + high)>>1,l = low,r = mid+1,s = low,cnt = low; 32 for(int i = low; i <= high; ++i) 33 if(By[i].index <= mid) Bz[l++] = By[i]; 34 else Bz[r++] = By[i]; 35 for(int i = low; i <= high; ++i) By[i] = Bz[i]; 36 ret = min(closet(low,mid),closet(mid+1,high)); 37 for(l = low,r = mid+1; l <= mid && r <= high;) 38 if(Bz[l].y < Bz[r].y) tmp[s++] = Bz[l++]; 39 else tmp[s++] = Bz[r++]; 40 while(l <= mid) tmp[s++] = Bz[l++]; 41 while(r <= high) tmp[s++] = Bz[r++]; 42 for(int i = low; i <= high; ++i) By[i] = Bz[i] = tmp[i]; 43 for(int i = low; i <= high; ++i) 44 if(fabs(Bz[i].x - Bz[mid].x) < ret) tmp[cnt++] = Bz[i]; 45 for(int i = low; i < cnt; ++i) 46 for(int j = i + 1; j < cnt && Bz[j].y - Bz[i].y < ret; ++j) 47 ret = min(ret,calc(Bz[i],Bz[j])); 48 return ret; 49 } 50 int main(){ 51 int n; 52 while(scanf("%d",&n),n){ 53 for(int i = 0; i < n; ++i) 54 scanf("%lf %lf",&Bx[i].x,&Bx[i].y); 55 sort(Bx,Bx+n,cmpx); 56 for(int i = 0; i < n; ++i) 57 By[i] = Point(Bx[i].x,Bx[i].y,i); 58 sort(By,By+n,cmpy); 59 printf("%.2f\n",closet(0,n-1)/2); 60 } 61 return 0; 62 }