啊啊啊啊啊啊啊啊啊,dalao们帮帮我吧QAQ

P3810 【模板】三维偏序(陌上花开)

oTL
by resftlmuttmotw @ 2019-02-16 21:09:49


调试一下? ~~我没写过这个题~~
by No268435 @ 2019-02-16 21:10:13


@[殇の星辰](/space/show?uid=108975) orz dalao tql ddw
by CYJian @ 2019-02-16 21:10:14


@[殇の星辰](/space/show?uid=108975) orz dalao tql ddw
by No268435 @ 2019-02-16 21:12:19


woc 你们就不能说点人话么 非要这么嘲讽么 小机房的dalao们 (我已经非常非常友善了诶)
by Enquir @ 2019-02-16 21:30:46


@[No268435](/space/show?uid=108757) 我的Dev炸了,一调试就卡退
by Enquir @ 2019-02-16 21:31:18


@[殇の星辰](/space/show?uid=108975) 您的程序有四个bug,都在程序里改了 ```cpp #include<bits/stdc++.h> using namespace std; int n,k; int tmp,top,cnt; struct haha { int x,y,z,w,ans; }a[100005],b[100005]; int t[200005],ha[200005]; bool com1(haha x,haha y) { if(x.x!=y.x) return x.x<y.x; if(y.y!=x.y) return x.y<y.y; return x.z<y.z; } bool com2(haha x,haha y) { if(x.y!=y.y) return x.y<y.y; return x.z<y.z; } int lowbit(int x) { return x&(-x); } void add(int x,const int key) { while(x<=k) { t[x]+=key; x+=lowbit(x); } } int ask(int x) { int ans=0; while(x) { ans+=t[x]; x-=lowbit(x); } return ans; } void cdq(int l,int r) { if(l==r) return ; int j=l; int mid=(l+r)>>1; cdq(l,mid);cdq(mid+1,r); sort(a+l,a+mid+1,com2);sort(a+mid+1,a+r+1,com2); for(int i=mid+1;i<=r;i++) { while(a[i].y>=a[j].y&&j<=mid) //1.a[i].y>=a[j].y应该是大于等于 add(a[j].z,a[j].w),j++; a[i].ans+=ask(a[i].z); } for(int i=l;i<j;i++) add(a[i].z,-a[i].w); } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) scanf("%d%d%d",&b[i].x,&b[i].y,&b[i].z); sort(b+1,b+n+1,com1);//对b数组sort for(int i=1;i<=n;i++) { tmp++; if(b[i].x!=b[i+1].x||b[i].y!=b[i+1].y||b[i].z!=b[i+1].z) a[++top]=b[i],a[top].w=tmp,tmp=0; } cnt=n;n=top;cdq(1,n); for(int i=1;i<=n;i++) ha[a[i].ans+a[i].w-1]+=a[i].w; for(int i=1;i<=cnt;i++)//i<=cnt而不是top printf("%d\n",ha[i - 1]);//打印i - 1位 return 0; } ```
by yy1695651 @ 2019-03-19 08:03:56


@[yy1695651](/space/show?uid=76226) 感谢巨佬
by Enquir @ 2019-03-19 21:49:52


|