标签:mat tin string family algo har 统计 row return
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 18021 | Accepted: 6755 |
Description
Input
Output
Sample Input
1 2 10 C 2 1 2 2 Q 2 2 C 2 1 2 1 Q 1 1 C 1 1 2 1 C 1 2 1 2 C 1 1 2 2 Q 1 1 C 1 1 2 1 Q 2 1
Sample Output
1 0 0 1
Source
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int c[1010][1010] ;
int lowbit(int x)
{
return x & -x ;
}
void add(int i,int j,int d)
{
int x , y ;
for(x = i ; x > 0 ; x -= lowbit(x))
for(y = j ; y > 0 ; y -= lowbit(y))
c[x][y] += d;
}
int sum(int i,int j,int n)
{
int a = 0 , x , y ;
for(x = i ; x <= n ; x += lowbit(x))
for(y = j ; y <= n ; y += lowbit(y))
a += c[x][y] ;
return a ;
}
int main()
{
int t , tt , i , j , n , m , x1 , y1 , x2 , y2 ;
char ch ;
scanf("%d", &t);
for(tt = 1 ; tt <= t ; tt++)
{
scanf("%d %d", &n, &m);
memset(c,0,sizeof(c));
while(m--)
{
getchar();
scanf("%c", &ch);
if( ch == ‘C‘ )
{
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
add(x2,y2,1);
add(x1-1,y2,-1);
add(x2,y1-1,-1);
add(x1-1,y1-1,1);
}
else
{
scanf("%d %d", &x1, &y1);
printf("%d\n", sum(x1,y1,n)%2 );
}
}
if(tt != t)
printf("\n");
}
return 0;
}
标签:mat tin string family algo har 统计 row return
原文地址:http://www.cnblogs.com/wzjhoutai/p/7015706.html