| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 
 | #include<cstdio>#include<cmath>
 #include<algorithm>
 #include<iostream>
 #include<cstdlib>
 #include<ctime>
 #define INF 9999999999.0
 using namespace std;
 
 struct node{
 double x,y;
 }a[2000010];
 int n;
 double ans=INF;
 
 bool cmp(node a,node b){
 return a.x<b.x;
 }
 double len(node a,node b){
 return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
 }
 void calc(){
 for (int i=1;i<=n;i++){
 for (int j=i+1;j<=i+5;j++){
 double temp;
 temp=len(a[i],a[j]);
 ans=min(ans,temp);
 }
 }
 }
 void around(int ds){
 for (int i=1;i<=n;i++){
 double x=a[i].x,y=a[i].y;
 double xn,yn;
 double xyu=0.0,yyu=0.0;
 xn= (x - xyu)*cos(ds) - (y - yyu)*sin(ds) + xyu ;
 yn= (x - xyu)*sin(ds) + (y - yyu)*cos(ds) + yyu ;
 a[i].x=xn;
 a[i].y=yn;
 }
 sort(a+1,a+1+n,cmp);
 calc();
 }
 
 int main(){
 srand(time(NULL));
 for (int i=1;i<=200009;i++){
 a[i].x=INF;a[i].y=INF;
 }
 
 scanf("%d",&n);
 for (int i=1;i<=n;i++){
 scanf("%lf%lf",&a[i].x,&a[i].y);
 }
 around(0);
 around(rand()%360);
 around(rand()%360);
 printf("%.4lf",ans);
 return 0;
 }
 
 
 |