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 接下来 ...
随机推荐
- 6、kvm克隆虚拟机
kvm克隆有两种方法可以使用先暂停kvm虚拟机 virsh suspend privi-server 方法一:对虚拟机本身直接clone virt-clone -o privi-server -n p ...
- Chapter12
package scalaimport java.awt.event.{ActionEvent, ActionListener}import javax.swing.JButton import sc ...
- Linux系统配置双网卡绑定bond0
1.bonding简述 双网卡配置设置虚拟为一个网卡实现网卡的冗余,其中一个网卡坏掉后网络通信仍可正常使用,实现网卡层面的负载均衡和高可用性.现在一般的企业都会使用双网卡接入,这样既能添加网络带宽,同 ...
- VMware安装CentOS7的详细过程
原文:https://www.jianshu.com/p/ce08cdbc4ddb?utm_source=tuicool&utm_medium=referral 本篇文章主要介绍了VMware ...
- java常见数据结构举例
1. ArrayList(参考) import java.util.*; public class Test{ public static void main(String [] args){ Arr ...
- java简单使用netty
一 整合 由于本人的学过的技术太多太乱了,于是决定一个一个的整合到一个springboot项目里面. 附上自己的github项目地址 https://github.com/247292980/spri ...
- CentOS 6.2安装nagios
nagios分为监控机和被监控机两类机器 监控主机:gserver150(192.168.111.150) 被监控主机:gserver151(192.168.111.151) 一. 监 ...
- juypter-notebook安装配置
juypter-notebook安装配置 Table of Contents 1. jupyter notebook概述 2. jupyter notebook安装 3. 在jupyter noteb ...
- 虚拟机安装CentOS7 Minimal、jdk和hadoop
虚拟机安装CentOS7 Minimal.jdk和hadoop Table of Contents 1. 安装版本 2. PD安装 3. vim安装和配置 4. 主机名变为bogon的解决办法 5. ...
- java - Socket简单编程实践
1.简介: 1)SOCKET是应用程序和网络之间的一个接口.SOCKET创建设置好以后,应用程序可以: 通过网络把数据发送到socket . 通过网络从socket接收数据.(通信的前提是应用程序知道 ...