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 ...
随机推荐
- cross_val_score 交叉验证与 K折交叉验证,嗯都是抄来的,自己作个参考
因为sklearn cross_val_score 交叉验证,这个函数没有洗牌功能,添加K 折交叉验证,可以用来选择模型,也可以用来选择特征 sklearn.model_selection.cross ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 网格系统实例:嵌套列
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Java基础 -3.4
反码(~) 在计算机中,负数以其正值的补码形式表达. 什么叫补码呢?这得从原码,反码说起. 原码:一个整数,按照绝对值大小转换成的二进制数,称为原码. 比如 00000000 00000000 000 ...
- 第1节 Scala基础语法:scala中的方法源码分析
val list=List(1,2,3,4) list.reduce((x:Int,y:Int)=>x+y)--->list.reduceLeft((x:Int,y:Int)=>x+ ...
- 谷歌下,因为给外层大容器设置 overflow:visible; 而导致问题,IE、火狐正常
#selector { height: auto !important; width: 1024px!important; margin: auto; overflow:visible !import ...
- SpringBoot项目中自定义注解的使用
1.定义注解接口 @Documented @Retention(RUNTIME) @Target(METHOD) public @interface MyLog { String value() ...
- alibaba sentinel限流组件 源码分析
如何使用? maven引入: <dependency> <groupId>com.alibaba.csp</groupId> <artifactId>s ...
- 本周总结(19年暑假)—— Part5
日期:2019.8.11 博客期:111 星期日
- git安装以及gitlib配置
安装Git:详见http://www.cnblogs.com/xiuxingzhe/p/9300905.html 开通gitlab(开通需要咨询所在公司的gitlab管理员)账号后,本地Git仓库和g ...
- pytorch梯度下降法讲解(非常详细)
pytorch随机梯度下降法1.梯度.偏微分以及梯度的区别和联系(1)导数是指一元函数对于自变量求导得到的数值,它是一个标量,反映了函数的变化趋势:(2)偏微分是多元函数对各个自变量求导得到的,它反映 ...