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 ...
随机推荐
- ios APP进程杀死之后和APP在后台接收到推送点击跳转到任意界面处理
https://www.jianshu.com/p/ce0dc53eb627 https://www.cnblogs.com/er-dai-ma-nong/p/5584724.html github: ...
- 【快学Docker】Docker镜像相关操作
前言 镜像是Docker的三大核心概念之一(另外两个分别是:容器和仓库). Docker运行容器前需要本地存在镜像,如果本地不存在镜像,Docker则会尝试从远端仓库拉去镜像.镜像是Docker一大核 ...
- nginx 与上游服务器建立连接的相关设置
向上游服务建立联系 Syntax: proxy_connect_timeout time; #设置TCP三次握手超时时间,默认60秒:默认超时后报502错误 Default: proxy_connec ...
- if,while,for循环
目录 if条件 while循环 for循环 拓展知识点 if条件 if 条件: code elif 条件: code else: code # 三元运算符 x = 10 y = 20 print(y ...
- 解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'
1.启动 SpringBoot项目报错,使用的是Springboot.Spring.Mybatis连接Mysql数据库,启动SpringBoot项目报错,错误如下所示: _____ .__/\ .__ ...
- SpringBoot 获得 properties 文件中数据方式
参考:https://blog.csdn.net/qq_37171353/article/details/78005845
- ubunut18.04 下安装 gitlab ce版,使用清华源
gitlab官方的ubuntu安装说明 https://about.gitlab.com/install/#ubuntu 该安装说明介绍的是gitlab-ee版本 按照该说明也能安装gitlab-ce ...
- Django学习 之 HTTP与WEB为Django做准备
一.HTTP 1.HTTP 简介 HTTP协议(HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准. ...
- [Linux] day07——查看及过滤文本
查看及过滤文本 =====================================cat concatenate -n 添加行号------------------- ...
- 攻防世界web进阶区(1)
1.题目地址:http://111.198.29.45:43589 页面提示打开robots文件,则: 页面有提示输入fl0g.php,那么 获取flag. 2.题目地址:http://111.198 ...