d3NtMDAw @ 2021-07-13 13:04:08
#include<bits/stdc++.h>
using namespace std;
int n,len;
struct point{
double x;
double y;
} pointset[200005];
double ans=0,anans=9999999999;
double dis(point a,point b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
bool cmp2(point a,point b)
{
return a.x!=b.x?a.x<b.x:a.y<b.y;
}
void work()
{
sort(pointset,pointset+n,cmp2);
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
{
anans=min(dis(pointset[i],pointset[j]),anans);
if((pointset[j].x-pointset[i].x)*(pointset[j].x-pointset[i].x)>anans)
break;
}
}
int main()
{
int i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%lf %lf",&pointset[i].x,&pointset[i].y);
work();
printf("%.4lf",sqrt(anans));
return 0;
}
by Cat_shao @ 2021-08-04 15:15:22
没旋转。