Pagini recente » Cod sursa (job #2003893) | Cod sursa (job #876372) | Cod sursa (job #180627) | Cod sursa (job #1033646) | Cod sursa (job #1758549)
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iomanip>
#define x first
#define y second
using namespace std;
ifstream f("cmap.in");
ofstream o("cmap.out");
const int nmx = 100002;
const double inf = 3000000000;
int n;
pair <double,double> v[nmx];
void citire()
{
f >> n;
for(int i = 1; i <= n; ++i)
f >> v[i].x >> v[i].y;
}
inline double dist(const pair <double,double> p1, const pair <double,double> p2)
{
return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
}
double divide(const int st, const int dr)
{
if(dr - st + 1 > 3)
{
int mij = (st + dr) / 2;
double minim = min(divide(st,mij),divide(mij+1,dr));
int st1 = max(st-7,1), dr1 = min(dr+7,n);
for(int i = st1; i <= dr1; ++i)
for(int j = i + 1; j <= i + 7 && j <= dr1; ++j) // ???
minim = min(minim,dist(v[i],v[j]));
return minim;
}
else
{
double minim = inf;
for(int i = st; i < dr; ++i)
for(int j = i + 1; j <= dr; ++j)
minim = min(minim,dist(v[i],v[j]));
return minim;
}
}
int main()
{
citire();
sort(v + 1, v + n + 1);
o << fixed << setprecision(6) << sqrt(divide(1,n));
return 0;
}