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 接下来 ...
随机推荐
- Luogu P2480 [SDOI2010]古代猪文 卢卡斯+组合+CRT
好吧刚开始以为扩展卢卡斯然后就往上套..结果奇奇怪怪又WA又T...后来才意识到它的因子都是质数...qwq怕不是这就是学知识学傻了.. 题意:$ G^{\Sigma_{d|n} \space C_n ...
- 定时备份mysql数据库
第一步:编写mysqldump备份数据库脚本,先新建txt文档,编辑内容为 @echo off set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%" ...
- Android Studio、adb
Android Studio:一个超级全的教程,mark~ https://www.cnblogs.com/laughingQing/p/5848425.html adb命令: https://blo ...
- Appium + Python自动化3 - 输入中文
在做app自动化过程中会踩很多坑,咱们都是用中文的app,所以首先要解决中文输入的问题!本篇通过屏蔽软键盘,绕过手机的软键盘方法,解决中文输入问题. 一.定位搜索 1.打开淘宝点击搜索按钮,进入搜索页 ...
- 016 3Sum Closest 最接近的三数之和
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- python操作json文件
import json class OperationJson(object): def __init__(self,file_name=None): if file_name: self.file_ ...
- 【Linux】ubuntu安装jdk-6u45-linux-x64.bin
for : Android4.4源码编译 环境 : ubuntu12.04_desktop_amd64 1. 1.1.jdk-6u45-linux-x64.bin 放置于 /home 1.2.命令&q ...
- jQuery 结构的实现思路
前提: 使用 JS 创建对象的最优办法,是 原型模式. step1: 原型模式的基础使用方式 function fn(){} fn.prototype = {} var ...
- 【踩坑】socket.io服务器不能访问
今天在单机测试socket.io服务器时一切正常,但用jar包的方式部署在服务器时发现客户端无法连接. 于是做了一系列排查,如检查端口是否在占用,防火墙有没有开放该端口,阿里云终端是否有开放安全组,本 ...
- JFrame 布局
引用文章:https://blog.csdn.net/zyj0813/article/details/78309739