Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

What is wrong with this code?

Posted by Jjjang at 2011-06-23 17:04:20 on Problem 2155 and last updated at 2011-06-23 17:04:31
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator