Pagini recente » Cod sursa (job #126669) | Cod sursa (job #182123) | Cod sursa (job #697798) | Cod sursa (job #2384544) | Cod sursa (job #1489025)
#include <bits/stdc++.h>
using namespace std;
const int nmax = 100005;
const int inf = 0x3f3f3f3f;
struct point {long long x, y;} t[nmax];
double sol;
double sqr(double x)
{
return (x*x);
}
bool cmp(point a, point b)
{
if (a.x==b.x) return (a.y < b.y);
else return (a.x < b.x);
}
double dist(point a, point b)
{
return sqrt(sqr(double(a.x-b.x))+sqr(double(a.y-b.y)));
}
long long ok(point a, point b)
{
if (a.x==b.x) return abs(double(b.y-a.y));
else return abs(a.x-b.x);
}
int main()
{
freopen("cmap.in", "r", stdin);
freopen("cmap.out", "w", stdout);
int i, j, n;
scanf("%d",&n);
for (i=1; i<=n; i++)
scanf("%lld %lld", &t[i].x, &t[i].y);
sort(t+1, t+n+1, cmp);
sol=1e16;
for (i=1; i<=n; i++)
for (j=i+1; j<=n && ok(t[i],t[j])<sol; j++)
if (abs(double(t[j].y-t[i].y))<sol) sol=min(sol,dist(t[j],t[i]));
printf("%f", sol);
fclose(stdin);
fclose(stdout);
return 0;
}