Pagini recente » Cod sursa (job #300068) | Cod sursa (job #2152920) | Cod sursa (job #2962600) | Cod sursa (job #152249) | Cod sursa (job #1412036)
#include <bits/stdc++.h>
#define punct pair<long long,long long>
#define x first
#define y second
#define mp make_pair
using namespace std;
punct p[100005];
int n, i, l, r;
double sol;
struct cmp
{
bool operator()(punct a, punct b)
{
return a.y < b.y;
}
};
double dist(punct a, punct b)
{
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
set<punct, cmp>s;
int main()
{
freopen("cmap.in", "r", stdin);
freopen("cmap.out", "w", stdout);
scanf("%d", &n);
for(i = 1; i <= n; i++)
scanf("%lld%lld", &p[i].x, &p[i].y);
sol=1<<30;
sort(p + 1, p + n + 1);
for(l = r = 1; r <= n; r++)
{
while(l <= r && p[r].x - p[l].x > sol)
{
s.erase(p[l]);
l++;
}
for(auto it = s.lower_bound(mp(0ll, p[r].y - sol)); it != s.end() && it->y - p[r].y <= sol;it++)
sol = min(sol, dist(*it, p[r]));
s.insert(p[r]);
}
printf("%.9lf", sol);
return 0;
}