Pagini recente » Cod sursa (job #889805) | Cod sursa (job #1223539) | Cod sursa (job #2147668) | Cod sursa (job #3211547) | Cod sursa (job #717645)
Cod sursa(job #717645)
// WAT TEH FUCK??
// dafaq O(N* log N)
#include<cstdio>
#include<cmath>
#include<list>
#include<vector>
#include<algorithm>
#define INF 1000000000.
using namespace std;
typedef unsigned long long ull;
struct point
{
int x,y;
};
bool lower_x (point A, point B)
{
return A.x<B.x;
}
double dist(point A, point B)
{
return sqrt(((ull)A.x-B.x)*(A.x-B.x) + ((ull)A.y-B.y)*(A.y-B.y));
}
int main()
{
freopen("cmap.in","r",stdin);
freopen("cmap.out","w",stdout);
int nP; scanf("%d",&nP);
vector<point> sweep;
for (int i=1;i<=nP;i++)
{
point tmp;
scanf("%d %d",&tmp.x,&tmp.y);
sweep.push_back(tmp);
}
sort(sweep.begin(),sweep.end(),lower_x);
//
double min_d=INF;
list<point> setEval;
for (int i=0; i<sweep.size(); i++)
{
point cur = sweep.at(i);
for (list<point>::iterator it=setEval.begin();it!=setEval.end();)
if (cur.x-(*it).x >= min_d) setEval.erase(it++);
else
{
if (dist(cur, *it)<min_d) min_d=dist(cur, *it);
++it;
}
setEval.push_back(cur);
}
printf("%lf", min_d);
return 0;
}