为什么vijos上AC,洛谷上全部RE?

P1429 平面最近点对(加强版)

@[lin\_toto](/space/show?uid=256)
by kimi0503 @ 2017-08-16 19:10:45


你没有用#include<bits/stdc++.h> using namespace std; 附上AC代码 ```cpp #include<bits/stdc++.h> using namespace std; 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 慕浟谭谈 @ 2017-08-16 19:23:10


@[jijiang](/space/show?uid=23750)
by 慕浟谭谈 @ 2017-08-16 19:29:13


@[32921653a](/space/show?uid=52996) 为什么会这样?
by kimi0503 @ 2017-08-16 19:30:16


@[jijiang](/space/show?uid=23750) 一个是调用万能库,比较方便(推荐) 第二个是必须有的
by 慕浟谭谈 @ 2017-08-16 19:51:27


问题在于我是RE而不是CE,没有万能库和using namespace std应该只会CE啊!
by kimi0503 @ 2017-08-16 22:08:57


@ 32921653a(另一个原因是我本地的万能库坏了,懒得修了)
by kimi0503 @ 2017-08-16 22:09:41


@[32921653a](/space/show?uid=52996)
by kimi0503 @ 2017-08-16 22:09:58


@[jijiang](/space/show?uid=23750) RE是运行时的错误,是没有using的原因
by 慕浟谭谈 @ 2017-08-17 09:25:45


@[32921653a](/space/show?uid=52996) 人家c/c++混写好吧,不用cin/cout而用scanf/printf只需要cstdio就行了。您是语言通吃的大佬
by 览遍千秋 @ 2017-08-17 10:17:38


| 下一页