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 ...
随机推荐
- sql between and
sql中的 a between 'a' and 'b' 基本上是代表 'a'>=a and 'b'<=a
- Ubuntu 12.04 root账户开启及密码重设
以普通用户登录,root账号的开启.关闭和密码设置,命令如下: sudo passwd -u root # 启用root账户 sudo passwd root # 设置root 密码(包括重设) su ...
- html img src base64
网页上有些图片的src或css背景图片的url后面跟了一大串字符,比如:data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAYAAABId ...
- Win7 配置Apache+PHP+Mysql环境
第一.安装并配置APACHE(安装到D:\phpapache\Apache2.2) 1.安装时默认安装,Network Domain, Server Name 我填写我的计算机名,Administra ...
- Ruby on rails学习笔记——安装环境
出现问题: C:\Users\len>gem install rails ERROR: While executing gem ... (Gem::RemoteFetcher::FetchErr ...
- 2012 Theory for Forward Rendering
http://miss-cache.blogspot.com/2012/08/lighting-transparent-surfaces-with_26.html http://aras-p.info ...
- DIV CSS 网页兼容全搞定 (IE6 IE7 IE8 IE9 火狐 谷歌)
CSS兼容常用技巧 请尽量用xhtml格式写代码,而且DOCTYPE影响 CSS 处理,作为W3C标准,一定要加DOCTYPE声明. 1.div的垂直居中问题 vertical-align:middl ...
- How to debug windows service
Step 1. Add the following code in what you want to debug. System.Diagnostics.Debugger.Launch(); Step ...
- C# 协变out 、逆变 in
需求:泛型使用多态性 备注:协变逆变只能修饰 接口和委托 简单理解: 1.使用 in 修饰后为逆变,只能用作形参使用 ,参考 public delegate void Action<in T&g ...
- eclipse的安装环境及eclipse下maven的配置安装
之前安装zookeeper的时候,就配置过linux下的java环境,即安装过linux JDK,配置过JAVA_HOME 和PATH 变量,,, 现在要运行一个java客户端,来消费kafka ...