Pagini recente » Cod sursa (job #3131785) | Cod sursa (job #889144) | Cod sursa (job #1884105) | Cod sursa (job #1344419) | Cod sursa (job #1913617)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int n;
struct punct
{
int x,y;
} vPuncte[100002];
vector<punct> ST,DR;
bool cmpX(punct p1,punct p2)
{
return p1.x<p2.x;
}
bool cmpY(punct p1,punct p2)
{
return p1.y<p2.y;
}
double dist(punct p1,punct p2)
{
double rez;
rez=sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
return rez;
}
void citire()
{
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
scanf("%d%d",&vPuncte[i].x,&vPuncte[i].y);
}
}
double solve()
{
sort(vPuncte+1,vPuncte+n+1,cmpX);
double rez;
rez=dist(vPuncte[1],vPuncte[2]);
for(int i=1; i<n; i++)
for(int j=i+1; j<=n&&vPuncte[j].x-vPuncte[i].x<rez; j++)
{
rez=min(rez,dist(vPuncte[i],vPuncte[j]));
}
return rez;
}
int main()
{
freopen("cmap.in","r",stdin);
freopen("cmap.out","w",stdout);
citire();
printf("%lf",solve());
return 0;
}