poj2155(树状数组,区间修改,点查询)
来源:互联网 发布:optisystem mac air 编辑:程序博客网 时间:2024/06/05 18:40
题目链接:点击打开链接
// poj2155// 题目大意:一个01矩阵,每次变换一个区间(0->1,1->0),问某个点是多少#include <iostream>#include <algorithm>#include <fstream>#include <sstream>#include <iomanip>#include <cstdio>#include <vector>#include <cstring>#include <cmath>#include <queue>#include <stack>#include <set>#include <map>#define L 1500using namespace std;int c[1500][1500], n;void add(int x, int y, int d){for(int i= x; i<= L; i+= i&-i)for(int j= y; j<= L; j+= j&-j)c[i][j]+= d;}int sum(int x, int y){int s= 0;for(int i= x; i> 0; i-= i&-i)for(int j= y; j> 0; j-= j&-j)s+= c[i][j];return s;}int main(){ int T, t; cin >> T; while(T--) { scanf("%d%d", &n, &t); memset(c, 0, sizeof(c)); while(t--) { char ch[10]; scanf("%s", ch); if(ch[0]== 'C') { int a, b, x, y; scanf("%d%d%d%d", &a, &b, &x, &y); x++; y++; add(x, y, 1); add(a, b, 1); add(x, b, 1); add(a, y, 1); } if(ch[0]== 'Q') { int x, y; scanf("%d%d", &x, &y); printf("%d\n", sum(x, y)& 1); } } if(T) printf("\n"); } return 0;}
阅读全文
0 0
- poj2155(树状数组,区间修改,点查询)
- POJ2155【二维树状数组,区间修改,点查询?】【又被输入输出坑】
- poj2155树状数组 区间更新 单点查询
- 树状数组单点更新和区间更新,二维数组poj2155(区间更新,单点查询)(已加入区间修改区间查询)
- 【树状数组】区间修改&点查询
- 【树状数组】点修改&区间查询
- hdu1556 树状数组 区间修改,点查询
- HDU 4031 Attack(树状数组修改区间查询点)
- hdu1556(树状数组/线段树,区间修改,点查询)
- hdu3584(三维树状数组,区间修改,点查询)
- poj2155-二维树状数组 区间更新 单点查询
- 【POJ2155】Matrix 二维线段树点修改区间查询
- HDU 1556(树状数组-区间修改,查询点)
- 树状数组应用之——区间修改 点查询
- POJ2155 Matrix 【二维树状数组】+【段更新点查询】
- 树状数组 区间修改查询
- 树状数组区间修改+查询
- POJ2155 Matrix 二维树状数组 修改区域,查询节点
- leetcode 15 3 sum 4 sum
- 奥威Power-BI旅游行业数据分析-按省份分析
- 其他-2017年流行的自动化测试工具
- 关于数据库乱码问题。
- ubuntu update和install失败,一种可以能的解决方法
- poj2155(树状数组,区间修改,点查询)
- 使用github搭建个人网站
- 7.odoo入门——初探odoo后台启动过程(一)
- 1040: [ZJOI2008]骑士
- gradle打包:Keystore file xxx not found for signing config
- iOS支付宝回调状态码
- Java8创建 stream的几种方式
- java读取mongoDB某个数据库的集合的指定字段值,并存入mysql数据库指定表中
- 解决办法 fonts/fontawesome-webfont.woff2 404 (Not Found)