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啊,郁闷。用位操作的,奇怪,没有超时,但是WA了,实在找不出错。 #include <stdio.h> #include <string.h> int n,m; unsigned a[1010][1000/32+10]; char buf[2]; int query(int x,int y) { int g=y>>5,h=y&31; return (a[x][g]>>h)&1; } void solve() { unsigned i,i1,i2,j1,j2; int x1,y1,x2,y2; unsigned x,u; unsigned w,w1,w2; for(i=0;i<n;i++) memset(a[i],0,sizeof(a[i])); while(m-->0) { scanf("%s",buf); if(buf[0]=='C') { scanf("%d%d%d%d",&x1,&y1,&x2,&y2); x1--,y1--,x2--,y2--; for(x=x1;x<=x2;x++) { i1=y1>>5,i2=y2>>5; j1=y1&31,j2=y2&31; if(i1==i2) { u=(1LL<<j1)-1; w1=a[x][i1]&u; a[x][i1]>>=j1; j2=j2-j1+1; u=(1LL<<j2)-1; w2=(~a[x][i1])&u; a[x][i1]=((((a[x][i1]>>j2)<<j2)|w2)<<j1)|w1; } else { for(i=i1+1;i<i2;i++) a[x][i]=~a[x][i]; j2++; u=(1LL<<j2)-1; w=(~a[x][i2])&u; a[x][i2]=((a[x][i2]>>j2)<<j2)|w; u=(1LL<<j1)-1; w=a[x][i1]&u; a[x][i1]=(((~a[x][i1])>>j1)<<j1)|w; } } } else { scanf("%d%d",&x1,&y1); x1--,y1--; printf("%d\n",query(x1,y1)); } } } int main() { int casen; scanf("%d",&casen); while(casen-->0) { scanf("%d%d",&n,&m); solve(); if(casen>0) printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator