poj 2155 B - Matrix 二维树状数组
#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 二维树状数组的更多相关文章
- POJ 2155:Matrix 二维树状数组
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 21757 Accepted: 8141 Descripti ...
- POJ 2155 Matrix(二维树状数组,绝对具体)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 20599 Accepted: 7673 Descripti ...
- [poj2155]Matrix(二维树状数组)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 25004 Accepted: 9261 Descripti ...
- 【poj2155】Matrix(二维树状数组区间更新+单点查询)
Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...
- poj 2155 Matrix (二维树状数组)
题意:给你一个矩阵开始全是0,然后给你两种指令,第一种:C x1,y1,x2,y2 就是将左上角为x1,y1,右下角为x2,y2,的这个矩阵内的数字全部翻转,0变1,1变0 第二种:Q x1 y1,输 ...
- poj 1195 Mobile phones(二维树状数组)
树状数组支持两种操作: Add(x, d)操作: 让a[x]增加d. Query(L,R): 计算 a[L]+a[L+1]……a[R]. 当要频繁的对数组元素进行修改,同时又要频繁的查询数组内任一 ...
- poj----2155 Matrix(二维树状数组第二类)
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 16950 Accepted: 6369 Descripti ...
- POJ2155:Matrix(二维树状数组,经典)
Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the ...
- Matrix 二维树状数组的第二类应用
Matrix Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 17976 Accepted: 6737 Descripti ...
随机推荐
- vue项目如何打包前后端不分离发布手把手教学apache、nginx
vue项目如何不分离发布 1.首先yarn build 我用了vue-cli脚手架,bulid后的dist文件夹里的index.html有加版本号,那么为什么需要加版本号呢? a.回滚 b.解决浏览器 ...
- 获取音、视频时长(NAudio,Shell32,FFmpeg)
参考网址:https://blog.csdn.net/u013810234/article/details/57471780 以下为本次测试用到的音.视频格式: audio :”.wav;.mp3;. ...
- Resharper插件安装和破解
1.首先在最下面的地址,下载Resharper安装包,进行解压安装,安装界面如下: a 2.安装后 解压下载好的 文件 会得到如下: 3.打开序列号 会看到如下所示: 4.然后 复制 %LocalA ...
- ubuntu多显示器单触摸屏校准
多显示器单触摸屏屏幕校准 0.触摸屏重定向 sudo xinput map-to-output 13 DP1 #将触摸屏映射到指定的显示器 其中:13为触摸屏设备id,可通过 xinput命令查看 ...
- delete和delete[] 区别
// DeleteAndDelete[].cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> ...
- fastIO
文件系统除了处理正常的IRP 之外,还要处理所谓的FastIo.FastIo是Cache Manager 调用所引发的一种没有irp 的请求.换句话说,除了正常的Dispatch Functions ...
- 对FPGA的时钟资源理解(更新中)
7系列FPGA中包含了多达24个CMT(时钟管理单元)(实际上V7常见只有20个),MMCM和PLL均为时钟综合器,对外部输入时钟.内部时钟进行处理,生成需要的低抖动时钟.PLL是MMCM的功能子集, ...
- Android开发 ---Button的OnClickListener的三种实现方法
button的OnClickListener的三种实现方法 onclick事件的定义方法,分为三种,分别为 1.在xml中进行指定方法: 2.在Actitivy中new出一个OnClickListen ...
- fk makefile文件的一些问题
除了要按具神说的makefile修改之外,还发现了另外一个问题: 不然就改成SACLIB=-L/usr/local/sac/lib
- 你真的会使用Github吗?
快捷键 r 快速引用 你可以选中别人的评论文字,然后按r,这些内容会以引用的形式被复制在文本框中: t:搜索文件 s:光标定位到搜索窗口 w:选择分支 g n Go to Notifications ...