Day6 - C - Count HYSBZ - 1452 /1452: [JSOI2009]Count
Description
Input
Output
对于每个操作2,按输入中出现的顺序,依次输出一行一个整数表示所求得的个数
Sample Input
1 2 3
3 2 1
2 1 3
3
2 1 2 1 2 1
1 2 3 2
2 2 3 2 3 2
Sample Output
2
#define lowbit(x) ((x)&(-x))
typedef long long LL; const int maxm = ; int C[maxm][maxm][], N, M, B[maxm][maxm]; void add(int x, int y, int val, int k) {
for(int i = x; i <= N; i += lowbit(i))
for(int j = y; j <= M; j += lowbit(j))
C[i][j][val] += k;
} int getsum(int x, int y, int val) {
int ret = ;
for(int i = x; i; i -= lowbit(i))
for(int j = y; j; j -= lowbit(j))
ret += C[i][j][val];
return ret;
} int range_getsum(int xa, int ya, int xb, int yb, int val) {
return getsum(xb, yb, val) - getsum(xb, ya-, val) - getsum(xa-, yb, val) + getsum(xa-, ya-, val);
} int main() {
scanf("%d%d", &N, &M);
int t;
for(int i = ; i <= N; ++i)
for(int j = ; j <= M; ++j) {
scanf("%d", &t);
B[i][j] = t;
add(i, j, t, );
}
int Q, type, xa, xb, ya, yb, c;
scanf("%d", &Q);
while(Q--) {
scanf("%d", &type);
if(type == ) {
scanf("%d%d%d", &xa, &ya, &c);
add(xa, ya, B[xa][ya], -);
B[xa][ya] = c;
add(xa, ya, c, );
} else if(type == ) {
scanf("%d%d%d%d%d", &xa, &xb, &ya, &yb, &c);
printf("%d\n", range_getsum(xa, ya, xb, yb, c));
}
}
return ;
}
Day6 - C - Count HYSBZ - 1452 /1452: [JSOI2009]Count的更多相关文章
- BZOJ 1452:[JSOI2009]Count(二维树状数组)
[JSOI2009]Count 描述 输入 输出 1 2 分析: 裸二维bit,对每个颜色建一颗bit. program count; var bit:..,..,..]of longint; a:. ...
- 【BZOJ 1452】 [JSOI2009]Count
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 维护一百个二维树状数组. 二维区间求和. [代码] #include <bits/stdc++.h> #define L ...
- BZOJ 1452: [JSOI2009]Count 二维树状数组
1452: [JSOI2009]Count Description Input Output Sample Input Sample Output 1 2 HINT Source 题解:设定C[101 ...
- BZOJ 1452: [JSOI2009]Count(二维BIT)
为每一个权值开一个二维树状数组. ------------------------------------------------------------------------- #include& ...
- [bzoj1452][JSOI2009]Count(树状数组)
1452: [JSOI2009]Count Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 2057 Solved: 1216[Submit][Stat ...
- BZOJ1452 [JSOI2009]Count 【树套树 (树状数组)】
1452: [JSOI2009]Count Time Limit: 10 Sec Memory Limit: 64 MB Submit: 2693 Solved: 1574 [Submit][St ...
- BZOJ1452 [JSOI2009]Count [2017年4月计划 树状数组02]
1452: [JSOI2009]Count Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 2419 Solved: 1403[Submit][Stat ...
- 【BZOJ1452】[JSOI2009]Count(树状数组)
[BZOJ1452][JSOI2009]Count(树状数组) 题面 BZOJ 洛谷 题解 数据范围这么小?不是对于每个颜色开一个什么东西记一下就好了吗. 然而我不会二维树状数组? 不存在的,凭借多年 ...
- 用count(*)还是count(列名) || Mysql中的count()与sum()区别
Mysql中的count()与sum()区别 首先创建个表说明问题 CREATE TABLE `result` ( `name` varchar(20) default NULL, `su ...
- mysql提示Column count doesn't match value count at row 1错误
mysql提示Column count doesn't match value count at row 1错误,后来发现是由于写的SQL语句里列的数目和后面的值的数目不一致, 比如insert in ...
随机推荐
- nginx 的四层代理
需要编译四层模块 [root@python vhast]# cd ~/nginx-1.15.9/ [root@python nginx-1.15.9]# ./configure --prefix=/d ...
- 第4节 Scala中的actor介绍:1、actor概念介绍;2、actor执行顺序和发送消息的方式
10. Scala Actor并发编程 10.1. 课程目标 10.1.1. 目标一:熟悉Scala Actor并发编程 10.1.2. 目标二:为学习Akka做准备 注:Sca ...
- 事件类型-UI事件、焦点事件
DOM3级事件包括以下几类事件: UI事件:当用户与页面上的元素交互时触发 焦点事件:当元素获得或失去焦点时触发 鼠标事件:当用户通过鼠标在页面上执行操作时触发 滚轮事件:当使用鼠标滚轮时触发 文本事 ...
- 强制设置双缓冲DoubleBuffered 解决tableLayoutPanel 闪烁
tableLayoutPanel.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.In ...
- python如何画三维图像?
python三维图像输出的代码如下所示:#画3D函数图像输出from mpl_toolkits.mplot3d import Axes3Dfrom matplotlib import cmimport ...
- 网络协议-webService协议
webservice 协议 Web Service使用的是 SOAP (Simple Object Access Protocol)协议soap协议只是用来封装消息用的.封装后的消息你可以通过各种已有 ...
- c#数据四种执行方法(ExecuteNonQuery)-----转载
c#数据四种执行方法(ExecuteNonQuery) 1.使用ExecuteReader()操作数据库 2.使用ExecuteNonQuery()操作数据库 3.使用ExecuteScalar( ...
- jqGrid一次性读取本地数据
参考:http://blog.sina.com.cn/s/blog_54da57aa010154r7.html
- java 学习地址
数组 JAVA中数组排序小结 Java中ArrayList和LinkedList区别 在往里面插入数据时.LinkedList会比ArrayList快很多,因为前者仅仅做了一个类型的插入,而后者 ...
- spring mvc ,spring boot 整合swagger
https://blog.csdn.net/qq_35992900/article/details/81274436