1452: [JSOI2009]Count
Time Limit: 10 Sec Memory Limit: 64 MB
Submit: 3135 Solved: 1828
[Submit][Status][Discuss]
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
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int n,m,q;
int mp[][];
int t[][][]; int lowbit(int x){return x&(-x);}
void update(int x,int y,int c,int v)
{
for(int i=x;i<=n;i+=lowbit(i))
for(int j=y;j<=m;j+=lowbit(j))
t[c][i][j]+=v;
} int ask(int x,int y,int c)
{
int tmp=;
for(int i=x;i;i-=lowbit(i))
for(int j=y;j;j-=lowbit(j))
tmp+=t[c][i][j];
return tmp;
} int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
{
scanf("%d",&mp[i][j]);
update(i,j,mp[i][j],);
}
scanf("%d",&q);
while(q--)
{
int f;
scanf("%d",&f);
int x1,y1,x2,y2,c;
if(f==)
{
scanf("%d%d%d",&x1,&y1,&c);
update(x1,y1,mp[x1][y1],-);
mp[x1][y1]=c;
update(x1,y1,mp[x1][y1],);
}
else
{
scanf("%d%d%d%d%d",&x1,&x2,&y1,&y2,&c);
int ans=ask(x1-,y1-,c)+ask(x2,y2,c)-ask(x1-,y2,c)-ask(x2,y1-,c);
printf("%d\n",ans);
}
}
return ;
}
1452: [JSOI2009]Count的更多相关文章
- 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& ...
- 二维树状数组 BZOJ 1452 [JSOI2009]Count
题目链接 裸二维树状数组 #include <bits/stdc++.h> const int N = 305; struct BIT_2D { int c[105][N][N], n, ...
- 【BZOJ】1452: [JSOI2009]Count
http://www.lydsy.com/JudgeOnline/problem.php?id=1452 题意:n×m的矩阵上每个点有个颜色,现在有q个操作:1 x y c 将点(x,y)的颜色改为c ...
- bzoj 1452: [JSOI2009]Count (二维树状数组)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1452 思路: 对每个颜色开一个二维树状数组维护就好了 实现代码: #include<b ...
- BZOJ 1452 [JSOI2009] Count
这道题好像有点简单的样子... absi找题目好厉害啊...确实是一道比较裸的2dBIT啊. 水掉吧. 附:2dBIT怎么做: 2dBIT就是BIT套BIT啦. 所以修改loop(x+=lowbit( ...
- 1452: [JSOI2009]Count - BZOJ
Description Input Output Sample Input Sample Output 1 2HINT 一开始还想什么离线做,其实不用,空间足够,我们直接开100个二维树状数组,然后就 ...
- bzoj 1452: [JSOI2009]Count ——二维树状数组
escription Input Output Sample Input Sample Output 1 2 HINT ———————————————————————————————————————— ...
- Day6 - C - Count HYSBZ - 1452 /1452: [JSOI2009]Count
Description 一个N*M的方格,初始时每个格子有一个整数权值,接下来每次有2个操作: 改变一个格子的权值 求一个子矩阵中某个特定权值出现的个数 Input 每一行有两个数字N,M 接下来 ...
随机推荐
- 前端 HTML-CSS 规范
黄金定律 一个项目应该永远遵循同一套编码规范! 不管有多少人共同参与同一项目,一定要确保每一行代码都像是同一个人编写的. HTML 语法 用两个空格来代替制表符(tab) – 这是唯一能保证在所有环境 ...
- Git 2016视频教程
http://blog.csdn.net/biggbang/article/details/50830331
- 使用C#连接 MyCat 链接串
所属专栏: mycat的安装部署以及监控和运维 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u014180504/article/detai ...
- win10卸载更新+关闭自动更新的方法
卸载更新方法: 左下角->设置->更新和安全->windows更新->高级选项->查看更新历史记录->卸载更新 关闭自动更新的方法:win+r 输入service ...
- javaweb项目导入myecplise出错
项目导入出错:移动项目的时候.classpath .project不要删 build path -> use for source floder 把某一文件夹当作源码文件夹 bulid path ...
- Spring和springMVC父子容器的关系
部分转载自:https://www.cnblogs.com/ljdblog/p/7461854.html springMVC容器和Spring容器 为什么一定要在web.xml中配置spring的li ...
- <linux下extmail服务的搭建>
下载2个软件包: extmail-1.1.0.tar.gz extman-1.1.tar.gz 下载地址:http://www.cpan.org/ 创建extsuite目录 mkdir /va ...
- 50道CSS基础面试题(附答案)
1 介绍一下标准的CSS的盒子模型?与低版本IE的盒子模型有什么不同的? 标准盒子模型:宽度=内容的宽度(content)+ border + padding + margin低版本IE盒子模型:宽度 ...
- vue封装storage案例
src/model/storage.js var storage={ set(key,value){ localStorage.setItem(key,JSON.stringify(value)); ...
- C/C++ sort函数的用法
sort函数的用法(#include<algorithm>) 做ACM题的时候,排序是一种经常要用到的操作.如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比 ...