BZOJ1452——[JSOI2009]Count
1、题目大意: 就是给一个n×m的方格,然后一些平面上的 求和 修改操作
2、分析:二维树状数组裸题
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int C[110][310][310];
int a[310][310];
int n, m;
inline void add(int c, int x, int y, int z){
for(; x <= n; x += (x & -x)){
int yy = y;
for(; yy <= m; yy += (yy & -yy)){
C[c][x][yy] += z;
}
}
return;
}
inline int query(int c, int x, int y){
int res = 0;
for(; x > 0; x -= (x & -x)){
int yy = y;
for(; yy > 0; yy -= (yy & -yy)){
res += C[c][x][yy];
}
}
return res;
}
int main(){
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
int c; scanf("%d", &c);
add(c, i, j, 1); a[i][j] = c;
}
}
int Q;
scanf("%d", &Q);
while(Q --){
int op, x1, y1, x2, y2, c;
scanf("%d", &op);
if(op == 1){
scanf("%d%d%d", &x1, &y1, &c);
add(a[x1][y1], x1, y1, -1);
add(c, x1, y1, 1);
a[x1][y1] = c;
}
else{
scanf("%d%d%d%d%d", &x1, &x2, &y1, &y2, &c);
printf("%d\n", query(c, x2, y2) - query(c, x1 - 1, y2) - query(c, x2, y1 - 1) + query(c, x1 - 1, y1 - 1));
}
}
return 0;
}
BZOJ1452——[JSOI2009]Count的更多相关文章
- [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
Description Input Output Sample Input Sample Output 1 2 HINT 正解:二维树状数组 解题报告: 这是一道送肉题.二维树状数组直接维护每种颜色的 ...
- bzoj1452 [JSOI2009]Count ——二维树状数组
中文题面,给你一个矩阵,每一个格子有数字,有两种操作. 1. 把i行j列的值更改 2. 询问两个角坐标分别为(x1,y1) (x2,y2)的矩形内有几个值为z的点. 这一题的特点就是给出的z的数据范围 ...
- 【二维树状数组】bzoj1452 [JSOI2009]Count
权值的种类只有100种,对每种开个二维BIT,然后是经典操作. #include<cstdio> using namespace std; ][]; struct BIT_2D { ][] ...
- 【BZOJ1452】[JSOI2009]Count(树状数组)
[BZOJ1452][JSOI2009]Count(树状数组) 题面 BZOJ 洛谷 题解 数据范围这么小?不是对于每个颜色开一个什么东西记一下就好了吗. 然而我不会二维树状数组? 不存在的,凭借多年 ...
- [bzoj1452][JSOI2009]Count_树状数组
Count bzoj-1452 JSOI-2009 题目大意:请维护一个平面内的数据结构,支持:单点修改,查询矩形内给定权值出现次数. 注释:$1\le n,m\le 300$,$1\le Q \le ...
- 【BZOJ-1452】Count 树状数组 套 树状数组
1452: [JSOI2009]Count Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1769 Solved: 1059[Submit][Stat ...
随机推荐
- python调用ggsci.exe程序
需求:通过python调用windows server 2008下的ogg同步程序,实现图形化控制. 简单GUI
- mysql导出到ms sql
导出为ms access数据库,然后在ms sql server管理器中导入就可以了,用csv.sql文件的方式都没成功
- uC/OS-II测试(TEST)块
/*************************************************************************************************** ...
- 重新注册iis的.NET Framework版本
说一个简单的方法,在VS2012.win7 sp1下亲测可用. 在开始菜单中找到VS 2012开发人员命令提示,然后执行命令:aspnet_regiis.exe -i 运行完成后截图如下:
- java内存配置
使用Java程序从数据库中查询大量的数据时出现异常:java.lang.OutOfMemoryError: Javaheap space 在JVM中如果98%的时间是用于GC且可用的 Heap siz ...
- pyinstaller 官方介绍
http://www.pyinstaller.org/ pyinstaller支持多个平台,windows,linux,mac,兼容多个第三方包,包括pyqt,django,matplotlib Py ...
- 用jackson封装的JSON工具类
package hjp.smart4j.framework.util; import com.fasterxml.jackson.databind.ObjectMapper; import org.s ...
- Runner站立会议06
开会时间:21.10~21.30 地点:基教负一 今天做了什么:日历布局,晚善日历 明天准备做什么:完善日历界面 遇到的困难:暂无 燃尽图: 会议图:
- ConterReplaceBehavior.class.php模板内容替换,如__PUBLIC__
ConterReplaceBehavior.class.php查找 __PUBLIC__ protected function templateContentReplace($content) { / ...
- AOP PostSharp
using System; using System.Collections.Generic; using System.Linq; using System.Text; using PostShar ...