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

水之!!!

Posted by wocha at 2012-08-15 16:26:16 on Problem 2155
#define stop system("pause")
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define N 1100
using namespace std;
int lowbit(int i){
	return (i&(-i));
}
int c[N][N],n;
void updat(int x,int y,int val){			
    	for (;x<=n;x+=lowbit(x))
         for (int i=y;i<=n;i+=lowbit(i))
             c[x][i]+=val;

	       
}
int getsum(int x,int y){
	int sum = 0;
	for( ;x;x-=lowbit(x))
	  for(int i=y;i;i-=lowbit(i))
	        sum += c[x][i];
	return sum;
}
int main(){
 int ca;
 cin>>ca;int o=0;
 while(ca--){
 	if(o) puts("");
 	o++;
 	int m;
 	memset(c,0,sizeof(c));
 	scanf("%d%d",&n,&m);
 	while(m--){
 		char str[55];
	 	scanf("%s",str);
	 	if(str[0]=='C'){
	 		int x1,x2,y1,y2;
	 		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	 		updat(x1, y1, 1);
			updat(x2 + 1, y2 + 1, -1);
			updat(x1, y2 + 1, -1);
			updat(x2 + 1, y1, -1);
	 	}
	 	else {
	 		int a,d;
	 		cin>>a>>d;
	 		printf("%d\n",getsum(a,d)&1);
	 	}
	 }
 }
}

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