kimi0503 @ 2017-08-16 19:10:16
如题,我知道可能是两者环境不同之类的,但是有大佬能具体地为我解释到底是什么问题导致我RE吗?我已被坑了2小时。
'''cpp
//#pr\agma GCC optimize("O2")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
const int N=2000010;
typedef double db;
typedef long long ll;
struct poi{
ll x,y;
inline friend ll dis(const poi a,const poi b){
return 1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y);
}
}a[N],b[N];
inline bool cmpx(const poi&a,const poi&b){
return a.x<b.x;
}
inline bool cmpy(const poi&a,const poi&b){
return a.y<b.y;
}
int n,i;
inline void up(ll&x,const ll&y){
if(x>y)x=y;
}
inline ll min(const ll&x,const ll&y){
return x>y?y:x;
}
inline ll sqr(ll x){
return x*x;
}
ll solve(int l,int r){
if(l>=r-2)return l==r-1?dis(a[l],a[r]):min(min(dis(a[l],a[l+1]),dis(a[l+1],a[l+2])),dis(a[l+2],a[l]));
int m=(l+r)>>1,u,i,s,t,v,j;
ll dd=min(solve(l,m),solve(m+1,r)),x=(a[m].x+a[m+1].x)/2,d=dd;
for(s=m;s>=l && sqr(a[s].x-x)<=dd;--s)b[s]=a[s];
for(t=m+1;t<=r && sqr(a[t].x-x)<=dd;++t)b[t]=a[t];
++s,--t;
std::sort(b+s,b+m+1,cmpy);
std::sort(b+m+1,b+t+1,cmpy);
for(i=s,u=v=m+1;i<=m;++i){
while(dd<sqr(b[i].y-b[u].y) && b[u].y<=b[i].y)++u;
while(v<=t && (b[v].y<=b[i].y || (b[v].y-b[i].y)<=dd))++v;
--v;
for(j=u;j<=v;++j)up(d,dis(b[i],b[j]));
}
return d;
}
int main(){
//freopen("1.txt","r",stdin);
//freopen("2.txt","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;++i)scanf("%lld%lld",&a[i].x,&a[i].y);
if(n==1){
puts("0");
return 0;
}
std::sort(a+1,a+n+1,cmpx);
printf("%.4f\n",sqrt(solve(1,n)));
return 0;
}
'''
by WJCwjc142857 @ 2017-10-11 21:50:51
by GCC314 @ 2018-02-12 12:31:20
输入是double啊
by Heartlessly @ 2018-03-17 14:30:04
评测机只要检测到freopen直接给RE,注释也没用
by feng_chengjie @ 2018-05-01 00:29:48
这就不正确了吧。。。