Pagini recente » Cod sursa (job #30261) | Cod sursa (job #1164037) | Cod sursa (job #477508) | Cod sursa (job #1029151) | Cod sursa (job #1512098)
#include<bits/stdc++.h>
using namespace std;
typedef struct lol {
double x,y;
}troll;
struct CMP {
bool operator () (const troll &a,const troll &b) const
{
return a.y<b.y;
}
};
int i,n,l,r;
double rs=1e18;
set <troll,CMP> s;
set <troll>::iterator it;
troll a[100005];
bool cmp(const troll &a,const troll &b) { return a.x<b.x; }
double dist(troll a,troll b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); }
int main()
{
ifstream cin("cmap.in");
ofstream cout("cmap.out");
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(i=1;i<=n;++i) cin>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
for(l=r=1;r<=n;++r)
{
while(l<r && a[l].x+rs+1<a[r].x) s.erase(a[l++]);
troll aux;
aux.x=0; aux.y=a[r].y-rs-1;
for(it=s.lower_bound(aux);it!=s.end() && it->y<=a[r].y+rs;++it) rs=min(rs,dist(*it,a[r]));
s.insert(a[r]);
}
cout<<setprecision(10)<<fixed<<rs<<'\n';
return 0;
}