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 ...
随机推荐
- Yocto开发笔记之《驱动调试-华为3G模块》(QQ交流群:519230208)
QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样 ======================================================== 参考:ht ...
- MySQL安装图解
MySQL安装图解 打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行“setup.exe”,出现如下界面: mysql安装向导启动,按“N ...
- MFC学习-第2,3课 MFC框架的运行机制
转自:http://blog.163.com/zhigang0633@126/blog/static/38790491200822711526168/ 讲述MFC AppWizard的原理与MFC程序 ...
- MySQL缺失mysql_config文件
打算爬虫,安装mysqldb 结果使用pip安装出错 在centos-6.4上pip install mysql-python,报错如下[sentry@kjtest111 mysql-python]$ ...
- Java简单的系统登陆
class Check{ public boolean validate(String name,String password){ if(name.equals("lixinghua&qu ...
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【四】——实现模型工厂,依赖注入以及格式配置
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 在上一篇中,我们已经初步开始使用Web Api了,但同时出现了一些很多不足之处,本章我们就着 ...
- MSSQL数据库链接字符串Asynchronous Processing=true不是异步查询吗,怎么是缓存
;Asynchronous Processing=true 不是异步查询吗,怎么是缓存 <!--<add name="default" providerName=&q ...
- 数据库操作事务IsolationLevel 枚举
成员名称 说明 Chaos 无法覆盖隔离级别更高的事务中的挂起的更改. ReadCommitted 在正在读取数据时保持共享锁,以避免脏读,但是在事务结束之前可以更改数据,从而导致不可重复 ...
- 性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework
http://www.xuebuyuan.com/356638.html 选择MiniProfiler.EF 默认会把MiniProfiler安装上,笔者程序是Asp.Net WebForm 不需要安 ...
- testNg vs junit 4.X @Test
http://www.ibm.com/developerworks/cn/java/j-cq08296/ 一个简单的测试用例 初看起来,JUnit 4 和 TestNG 中实现的测试非常相似.为了更好 ...