Pagini recente » Cod sursa (job #2381856) | Cod sursa (job #1796095) | Cool research papers | Autentificare | Cod sursa (job #2074037)
#include <iostream>
#include <fstream>
#include <math.h>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
#define nmax 100001
#define inf 10000000000
bool comp(pair <long,long> a, pair <long,long> b)
{
return a.first<b.first;
}
//vector <pair <long,long> > v;
pair<long, long> v[nmax];
long double d(pair<long,long> a, pair<long, long> b)
{
return sqrt(pow((a.first-b.first),2) + pow((a.second-b.second),2));
}
long double solve(int a, int b)
{
if(a==b) return inf;
if(b-a==1) return d(v[a],v[b]);
int m = (a+b)/2;
long double rez=min(solve(a,m),solve(m+1,b));
int aux[nmax],k=1;
for(int i=a;i<=m;++i)
if(v[m].first-v[i].first<rez) aux[k]=i,++k;
for(int j=1;j<=k;++j)
for(int i=1;i<8&&((j+i)<=b);++i)
rez=min(rez,d(v[j],v[i+j]));
return rez;
}
int main()
{
int n;
pair<long,long> aux;
f>>n;
for(int i=1;i<=n;++i)
{
f>>aux.first>>aux.second;
v[i]=aux;
}
sort(v+1,v+n+1,comp);
g<<fixed<<setprecision(7)<<solve(1,n);
}