#include<algorithm>#include<cmath>#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;constintmaxn=200010;intn,d[maxn],lc[maxn],rc[maxn];doubleans=2e18;structnode{doublex,y;}s[maxn];doubleL[maxn],R[maxn],D[maxn],U[maxn];doubledist(inta,intb){return(s[a].x-s[b].x)*(s[a].x-s[b].x)+(s[a].y-s[b].y)*(s[a].y-s[b].y);}boolcmp1(nodea,nodeb){returna.x<b.x;}boolcmp2(nodea,nodeb){returna.y<b.y;}voidmaintain(intx){L[x]=R[x]=s[x].x;D[x]=U[x]=s[x].y;if(lc[x])L[x]=min(L[x],L[lc[x]]),R[x]=max(R[x],R[lc[x]]),D[x]=min(D[x],D[lc[x]]),U[x]=max(U[x],U[lc[x]]);if(rc[x])L[x]=min(L[x],L[rc[x]]),R[x]=max(R[x],R[rc[x]]),D[x]=min(D[x],D[rc[x]]),U[x]=max(U[x],U[rc[x]]);}intbuild(intl,intr){if(l>r)return0;if(l==r){maintain(l);returnl;}intmid=(l+r)>>1;doubleavx=0,avy=0,vax=0,vay=0;// average variancefor(inti=l;i<=r;i++)avx+=s[i].x,avy+=s[i].y;avx/=(double)(r-l+1);avy/=(double)(r-l+1);for(inti=l;i<=r;i++)vax+=(s[i].x-avx)*(s[i].x-avx),vay+=(s[i].y-avy)*(s[i].y-avy);if(vax>=vay)d[mid]=1,nth_element(s+l,s+mid,s+r+1,cmp1);elsed[mid]=2,nth_element(s+l,s+mid,s+r+1,cmp2);lc[mid]=build(l,mid-1),rc[mid]=build(mid+1,r);maintain(mid);returnmid;}doublef(inta,intb){doubleret=0;if(L[b]>s[a].x)ret+=(L[b]-s[a].x)*(L[b]-s[a].x);if(R[b]<s[a].x)ret+=(s[a].x-R[b])*(s[a].x-R[b]);if(D[b]>s[a].y)ret+=(D[b]-s[a].y)*(D[b]-s[a].y);if(U[b]<s[a].y)ret+=(s[a].y-U[b])*(s[a].y-U[b]);returnret;}voidquery(intl,intr,intx){if(l>r)return;intmid=(l+r)>>1;if(mid!=x)ans=min(ans,dist(x,mid));if(l==r)return;doubledistl=f(x,lc[mid]),distr=f(x,rc[mid]);if(distl<ans&&distr<ans){if(distl<distr){query(l,mid-1,x);if(distr<ans)query(mid+1,r,x);}else{query(mid+1,r,x);if(distl<ans)query(l,mid-1,x);}}else{if(distl<ans)query(l,mid-1,x);if(distr<ans)query(mid+1,r,x);}}intmain(){scanf("%d",&n);for(inti=1;i<=n;i++)scanf("%lf%lf",&s[i].x,&s[i].y);build(1,n);for(inti=1;i<=n;i++)query(1,n,i);printf("%.4lf\n",sqrt(ans));return0;}
#include<algorithm>#include<cstring>#include<iostream>#include<queue>usingnamespacestd;constintmaxn=100010;longlongn,k;priority_queue<longlong,vector<longlong>,greater<longlong>>q;structnode{longlongx,y;}s[maxn];boolcmp1(nodea,nodeb){returna.x<b.x;}boolcmp2(nodea,nodeb){returna.y<b.y;}longlonglc[maxn],rc[maxn],L[maxn],R[maxn],D[maxn],U[maxn];voidmaintain(intx){L[x]=R[x]=s[x].x;D[x]=U[x]=s[x].y;if(lc[x])L[x]=min(L[x],L[lc[x]]),R[x]=max(R[x],R[lc[x]]),D[x]=min(D[x],D[lc[x]]),U[x]=max(U[x],U[lc[x]]);if(rc[x])L[x]=min(L[x],L[rc[x]]),R[x]=max(R[x],R[rc[x]]),D[x]=min(D[x],D[rc[x]]),U[x]=max(U[x],U[rc[x]]);}intbuild(intl,intr){if(l>r)return0;intmid=(l+r)>>1;doubleav1=0,av2=0,va1=0,va2=0;// average variancefor(inti=l;i<=r;i++)av1+=s[i].x,av2+=s[i].y;av1/=(r-l+1);av2/=(r-l+1);for(inti=l;i<=r;i++)va1+=(av1-s[i].x)*(av1-s[i].x),va2+=(av2-s[i].y)*(av2-s[i].y);if(va1>va2)nth_element(s+l,s+mid,s+r+1,cmp1);elsenth_element(s+l,s+mid,s+r+1,cmp2);lc[mid]=build(l,mid-1);rc[mid]=build(mid+1,r);maintain(mid);returnmid;}longlongsq(longlongx){returnx*x;}longlongdist(inta,intb){returnmax(sq(s[a].x-L[b]),sq(s[a].x-R[b]))+max(sq(s[a].y-D[b]),sq(s[a].y-U[b]));}voidquery(intl,intr,intx){if(l>r)return;intmid=(l+r)>>1;longlongt=sq(s[mid].x-s[x].x)+sq(s[mid].y-s[x].y);if(t>q.top())q.pop(),q.push(t);longlongdistl=dist(x,lc[mid]),distr=dist(x,rc[mid]);if(distl>q.top()&&distr>q.top()){if(distl>distr){query(l,mid-1,x);if(distr>q.top())query(mid+1,r,x);}else{query(mid+1,r,x);if(distl>q.top())query(l,mid-1,x);}}else{if(distl>q.top())query(l,mid-1,x);if(distr>q.top())query(mid+1,r,x);}}intmain(){cin>>n>>k;k*=2;for(inti=1;i<=k;i++)q.push(0);for(inti=1;i<=n;i++)cin>>s[i].x>>s[i].y;build(1,n);for(inti=1;i<=n;i++)query(1,n,i);cout<<q.top()<<endl;return0;}