POJ2155【二维树状数组模板】
来源:互联网 发布:广州网络推广公司 编辑:程序博客网 时间:2024/05/17 07:36
sum(i,j)%2 = 0/1的具体证明;
推荐一篇论文 浅谈信息学竞赛中的“0”和“1”.pdf(百度的到吧)
//#include<bits/stdc++.h>//using namespace std;//typedef long long LL;#include <stdio.h>#include <string.h>#include <iostream> #include <algorithm>using namespace std;typedef long long LL;const int N=1e3+10;int mat[N][N];int lowbit(int x){ return x&(-x);}void add(int x, int y, int d){ int i, j; for(i = x; i < N; i += lowbit(i)) for(j = y; j < N; j += lowbit(j)) mat[i][j] += d;}int sum(int x, int y){ int res = 0; int i, j; for(i = x; i > 0; i -= lowbit(i)) for(j = y; j > 0; j -= lowbit(j)) res += mat[i][j]; return res;}int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T; scanf("%d",&T); while(T--){ int n,q; char op[5]; int x1,x2,y1,y2; memset(mat,0,sizeof(mat)); scanf("%d%d",&n,&q); while(q--){ scanf("%s",op); if(op[0]=='C'){ scanf("%d%d%d%d",&x1,&y1,&x2,&y2); add(x1,y1,1); add(x2+1,y1,1); add(x1,y2+1,1); add(x2+1,y2+1,1); } else{ scanf("%d%d",&x1,&y1); if(sum(x1,y1)%2 == 0) puts("0"); else puts("1"); } } if(T>0) puts(""); } return 0;}
0 0
- POJ2155【二维树状数组模板】
- POJ2155(二维树状数组)
- 二维树状数组-poj2155
- poj2155二维树状数组
- poj2155 二维树状数组
- poj2155--Matrix--二维树状数组
- poj2155之二维树状数组
- POJ2155 Matrix(二维树状数组)
- poj2155 Matrix 【二维树状数组】
- poj2155~Matrix~二维树状数组!
- poj2155(二维树状数组)
- POJ2155 Matrix 二维树状数组
- poj2155 Matrix 【二维树状数组】
- 【poj2155】【二维树状数组】Matrix
- poj2155 Matrix 二维树状数组
- [POJ2155] Matrix - 二维树状数组
- 【POJ2155】Matrix(二维树状数组)
- POJ2155-Matrix-二维树状数组
- opencv学习起步(一)
- 运算符_键盘录入_流程控制语句
- [BZOJ2460][BeiJing2011]元素-线性基
- 爬虫软件爬取公开网络数据案例(以大众点评为例)
- 设计模式(二十一) 状态模式
- POJ2155【二维树状数组模板】
- 2016"百度之星"
- N皇后
- KMP模板+习题
- 【问题解决】Redis存储Hash-Map<String,Object>时无法序列化问题
- ZOJ 3768 Continuous Login
- js动态计算rem
- 可能的克服拖延症的方法
- HDU3787 A+B