Pagini recente » Cod sursa (job #1938074) | Cod sursa (job #722398) | Cod sursa (job #3039625) | Cod sursa (job #2938256) | Cod sursa (job #1413532)
#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 point pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
using namespace std;
const int nmax = 100005;
const double inf = 1e10;
int n, i, l, r;
point p[nmax];
double sol;
ll best;
struct cmp
{
bool operator () (const point &a, const point &b) const
{
return a.y < b.y;
}
};
set<point, cmp> s;
set<point>::iterator it;
double dist(point a, point b)
{
return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) + 1.0 * (a.y - b.y) * (a.y - b.y));
}
int main()
{
freopen("cmap.in", "r", stdin);
freopen("cmap.out", "w", stdout);
scanf("%d", &n);
for(i = 1; i <= n; i++)
scanf("%d%d", &p[i].x, &p[i].y);
sort(p + 1, p + n + 1);
sol = inf;
for(l = 1, r = 1; r <= n; r++)
{
best = (ll)sol + 1;
while(l < r && p[l].x + best < p[r].x)
{
s.erase(p[l]);
l++;
}
point aux = mp(0, p[r].y - best);
for(it = s.lower_bound(aux); it != s.end() && it->y <= p[r].y + best; it++)
sol = min(sol, dist(*it, p[r]));
s.insert(p[r]);
}
printf("%.10f\n", sol);
return 0;
}