| ||||||||||
| 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 | |||||||||
What is wrong with this code?#include <stdio.h>
int table[1050][1050], size, questions;
void change(int x, int y){
int y1;
while(x>0){
y1=y;
while(y1>0){
table[x][y1]=(table[x][y1]+1)%2;
y1-=(y1&-y1);
}
x-=(x&-x);
}
}
void read(int x, int y){
int y1, sum=0;
while(x<=size){
y1=y;
while(y1<=size){
sum+=table[x][y1];
y1+=(y1&-y1);
}
x+=(x&-x);
}
printf("%d\n", sum%2);
}
int main(){
int cases, a, b, c, x1, y1, x2, y2, x, y;
char command[15];
scanf("%d", &cases);
for(a=0;a<cases;a++){
scanf("%d %d", &size, &questions);
for(b=0;b<questions;b++){
scanf("%s", command);
if(command[0]=='C'){
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
change(x2, y2);
change(x2, y1-1);
change(x1-1, y2);
change(x1-1, y1-1);
}
else if(command[0]=='Q'){
scanf("%d%d", &x, &y);
read(x, y);
}
}
for(c=1;c<=size;c++){
for(b=1;b<=size;b++){
table[c][b]=0;
}
}
}
return 0;
}
This one made the presentation error... I don't know why,,,
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator