Pagini recente » Cod sursa (job #980302) | ojiliis | tema | Cod sursa (job #1550832) | Cod sursa (job #1645760)
#include <cmath>
#include <fstream>
#include <iomanip>
#include <algorithm>
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
struct pct
{
int x, y;
}a[100001];
int i, j, n;
double dmin = 1999999999;
bool cmp(pct a, pct b)
{
if (a.x < b.x)
return 1;
return 0;
}
double dist(pct a, pct b)
{
return sqrt((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y));
}
int main()
{
f >> n;
for (i = 1; i <= n; i++)
f >> a[i].x >> a[i].y;
sort (a+1, a+n+1, cmp);
for (i = 3; i <= n; i++)
{
j = i-1;
while (a[i].x - a[j].x < dmin && j >= 1)
dmin = min( dmin, dist(a[i], a[j]) ), j--;
}
g << fixed << setprecision(6) << dmin;
return 0;
}