#include<iostream>
#include<string>
#include<string.h>
#include<cstdio>
using namespace std;
const int maxn=;
int n;
int c[maxn][maxn];
int lowbit(int x) { return x&(-x); }
void update(int x,int y)
{
for(int i = x; i; i -= lowbit(i))
for(int j = y; j; j -= lowbit(j))
++c[i][j];
}
int query(int x, int y)
{
int sum = ;
for(int i = x; i <= n; i += lowbit(i))
for(int j = y; j <= n; j+= lowbit(j))
sum += c[i][j];
return sum;
}
int main()
{
int T; cin>>T;
while(T--)
{
memset(c,,sizeof(c));
int x; cin>>n>>x;
while(x--)
{
char s; cin>>s;
int a,b,c,d;
if(s == 'C')
{
cin>>a>>b>>c>>d;
update(c, b-);
update(a-, d);
update(a-, b-);
update(c, d);
}
else{cin>>a>>b; cout<<(query(a, b) & ? "" : "")<<endl; }
}
puts("");
}
}

poj 2155 B - Matrix 二维树状数组的更多相关文章

  1. POJ 2155:Matrix 二维树状数组

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 21757   Accepted: 8141 Descripti ...

  2. POJ 2155 Matrix(二维树状数组,绝对具体)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 20599   Accepted: 7673 Descripti ...

  3. [poj2155]Matrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25004   Accepted: 9261 Descripti ...

  4. 【poj2155】Matrix(二维树状数组区间更新+单点查询)

    Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...

  5. poj 2155 Matrix (二维树状数组)

    题意:给你一个矩阵开始全是0,然后给你两种指令,第一种:C x1,y1,x2,y2 就是将左上角为x1,y1,右下角为x2,y2,的这个矩阵内的数字全部翻转,0变1,1变0 第二种:Q x1 y1,输 ...

  6. poj 1195 Mobile phones(二维树状数组)

    树状数组支持两种操作: Add(x, d)操作:   让a[x]增加d. Query(L,R): 计算 a[L]+a[L+1]……a[R]. 当要频繁的对数组元素进行修改,同时又要频繁的查询数组内任一 ...

  7. poj----2155 Matrix(二维树状数组第二类)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16950   Accepted: 6369 Descripti ...

  8. POJ2155:Matrix(二维树状数组,经典)

    Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...

  9. Matrix 二维树状数组的第二类应用

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17976   Accepted: 6737 Descripti ...

随机推荐

  1. python 自然语言处理(六)____N-gram标注

    1.一元标注器(Unigram Tagging) 一元标注器利用一种简单的统计算法,对每个标注符分配最有可能的标记.例如:它将分配标记JJ给词frequent,因为frequent用作形容词更常见.一 ...

  2. 联想E431 安装ubuntu16.04

    http://jingyan.baidu.com/article/3c48dd348bc005e10be358eb.html 按照这个教程安装成功!!

  3. JavaScript -基础- 函数与对象(三)Date对象

    一.Date对象 1.创建方法 var date_obj=new Date(); alert(date_obj.toLocaleString()) var date_obj=new Date(&quo ...

  4. mac以及centos下安装Elasticsearch 以及权限管理插件

    Elasticsearch安装(提前系统需要安装java环境)mac安装 brew install elasticsearch centos安装 下载ElasticSearch安装包,https:// ...

  5. .net core webapi 配置swagger调试界面

    一.创建一个.net core webapi的项目: 二.在nuget程序包管理器控制台输入  Install-Package Swashbuckle -version 6.0.0-beta902   ...

  6. 运行TensorFlow出现Your CPU supports instructions that this TensorFlow binary was not compiled to use: AV

    原因: import os #在顶头位置加上 os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # '1'表示默认的显示等级,运行时显示所有信息 os. ...

  7. 2.13 C++拷贝构造函数

    参考:http://www.weixueyuan.net/view/6344.html 总结: 如果拷贝构造函数的参数不是对象的引用,则是不允许的.如 book(book b); 是无法编译通过的. ...

  8. linux,windows下日志文件查找关键词

    1.查找 /apps/tomcat/tomcat3/apache-tomcat-7.0.69/logs 目录下已.txt结尾的文件,在文件中搜索关键字 IfcmpEcrService并打印行号 /lo ...

  9. Spring学习四

    1先导入 Asject的jar包 2配置文件加入标签 ,并加入 <aop:aspectj-autoproxy proxy-target-class="true">(如果 ...

  10. nodejs --- querystring模块.

    1. 序列化: querystring.stringify(对象, 参数2, 参数3) 第二个参数 设置 连接符   从 & 变为 , 第三个参数 设置 key  和value的中间符号,  ...