Pagini recente » Cod sursa (job #2216259) | Cod sursa (job #3195468) | Monitorul de evaluare | Cod sursa (job #1357730) | Cod sursa (job #1295872)
#include<cstdio>
#include<fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
const int nmax = 100005;
const double inf = 1000000000000.0;
long long n, i, b, l, r;
double best, a;
struct point
{
long long x, y;
};
point p[nmax];
struct cmps
{
bool operator () (point a, point b) const
{
if(a.y == b.y) return a.x < b.x;
return a.y < b.y;
}
};
struct cmp
{
bool operator () (point a, point b) const
{
if(a.x == b.x) return a.y < b.y;
return a.x < b.x;
}
};
double dist(point a, point b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
set<point, cmps> s;
set<point>::iterator it;
int main()
{
ifstream fin("cmap.in");
ofstream fout("cmap.out");
fin >> n;
for(i = 1; i <= n; i++)
fin >> p[i].x >> p[i].y;
sort(p + 1, p + n + 1, cmp());
s.insert(p[1]);
best = inf;
l = 1;
for(r = 2; r <= n; r++)
{
b = (long long)(best + 1);
while(l < r && p[l].x + b < p[r].x)
{
s.erase(p[l]);
l++;
}
point aux;
aux.x = p[r].x;
aux.y = p[r].y - b;
it = s.lower_bound(aux);
while(it != s.end() && it->y <= p[r].y + b)
{
best = min(best, dist(*it, p[r]));
it++;
}
s.insert(p[r]);
}
fout << fixed << setprecision(7) << best;
return 0;
}