Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么老是WA,和以前的一个AC代码对拍了半个小时都没出错#include<iostream> #include<cstdio> using namespace std; int ans=0; int n,nOpe; int x,y,xx,yy; bool tree[4010][4010]; void Update1D(int ind,int root,int l,int r) { if(l>=y&&r<=yy) { tree[ind][root]=!tree[ind][root]; return ; } int mid=(l+r)>>1; if(mid>=y)Update1D(ind,root<<1,l,mid); if(mid<yy)Update1D(ind,(root<<1)+1,mid+1,r); } void Update2D(int root,int l,int r) { if(l>=x&&r<=xx) { Update1D(root,1,1,n); return ; } int mid=(l+r)>>1; if(mid>=x)Update2D(root<<1,l,mid); if(mid<xx)Update2D((root<<1)+1,mid+1,r); } void Query1D(int ind,int root,int l,int r) { if(tree[ind][root])ans++; if(l==r)return ; int mid=(l+r)>>1; if(mid>=y)Query1D(ind,root<<1,l,mid); else Query1D(ind,(root<<1)+1,mid+1,r); } void Query2D(int root,int l,int r) { Query1D(root,1,1,n); if(l==r)return ; int mid=(l+r)>>1; if(mid>=x)Query2D(root<<1,l,mid); else Query2D((root<<1)+1,mid+1,r); } int main() { int nCase; scanf("%d",&nCase); while(nCase--) { scanf("%d%d",&n,&nOpe); char ch; for(int i=1;i<=nOpe;i++) { cin>>ch; if(ch=='C') { scanf("%d%d%d%d",&x,&y,&xx,&yy); Update2D(1,1,n); } else { scanf("%d%d",&x,&y); ans=0; Query2D(1,1,n); printf("%d\n",ans&1); } } printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator