1452: [JSOI2009]Count】的更多相关文章

1452: [JSOI2009]Count Description Input Output Sample Input Sample Output 1 2 HINT Source 题解:设定C[101][N][N] 树状数组上价值为val的lowbit数组 //meek ///#include<bits/stdc++.h> #include <iostream> #include <cstdio> #include <cmath> #include <…
为每一个权值开一个二维树状数组. ------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream>   #define rep(i, n) for(int i = 0; i < n; ++i) #define Rep(i ,n…
题目链接 裸二维树状数组 #include <bits/stdc++.h> const int N = 305; struct BIT_2D { int c[105][N][N], n, m; void init(int n, int m) { memset (c, 0, sizeof (c)); this->n = n; this->m = m; } void updata(int k, int x, int y, int z) { for (int i=x; i<=n;…
http://www.lydsy.com/JudgeOnline/problem.php?id=1452 题意:n×m的矩阵上每个点有个颜色,现在有q个操作:1 x y c 将点(x,y)的颜色改为c:2 x1 x2 y1 y2 c 询问矩阵x1y1-x2y2颜色为c的格子数目 #include <bits/stdc++.h> using namespace std; const int N=301; int n, m; int S[101][N][N], col[N][N]; void up…
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1452 思路: 对每个颜色开一个二维树状数组维护就好了 实现代码: #include<bits/stdc++.h> using namespace std; ][][]; ][],n,m,q; int lowbit(int x){ return x&-x; } void add(int x,int y,int z,int rt){ for(int i = x;i <= n;i…
这道题好像有点简单的样子... absi找题目好厉害啊...确实是一道比较裸的2dBIT啊. 水掉吧. 附:2dBIT怎么做: 2dBIT就是BIT套BIT啦. 所以修改loop(x+=lowbit(x)){loop(y+=lowbit(y)){}} 查询loop(x-=lowbit(x)){loop(y-=lowbit(y)){}} 然后查询区间当然是用容斥... 假设查询(x1+1,y1+1)(x2,y2) 那么答案=Q(x1,y1)+Q(x2,y2)-Q(x1,y2)-Q(x2,y1) Q…
Description Input Output Sample Input Sample Output 1 2HINT 一开始还想什么离线做,其实不用,空间足够,我们直接开100个二维树状数组,然后就行了 但是如果c范围很大就离线做好一些 type tree=..,..]of longint; var s:..]of tree; a:..,..]of longint; n,m,q:longint; procedure add(var c:tree;x,y,w:longint); var i:lo…
escription Input Output Sample Input Sample Output 1 2 HINT —————————————————————————————————————————— 这道题是裸的二维树状数组.....直接每个颜色弄一个二维的树状数组然后容斥(也不知道算不算)就可以辣 #include<cstdio> #include<cstring> #include<algorithm> int read(){ ,f=,c=getchar();…
Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 3135  Solved: 1828[Submit][Status][Discuss] Description 一个N*M的方格,初始时每个格子有一个整数权值,接下来每次有2个操作: 改变一个格子的权值 求一个子矩阵中某个特定权值出现的个数   Input 每一行有两个数字N,M 接下来N行,每行M个数字.第i+1行第j个数字表示格子(i,j)的初值 接下来输入一个Q,后面Q行每行描述一个操作 操作1:…
Description 一个N*M的方格,初始时每个格子有一个整数权值,接下来每次有2个操作: 改变一个格子的权值 求一个子矩阵中某个特定权值出现的个数   Input 每一行有两个数字N,M 接下来N行,每行M个数字.第i+1行第j个数字表示格子(i,j)的初值 接下来输入一个Q,后面Q行每行描述一个操作 操作1: 1 x y c,表示将格子(x,y)的值变为c 操作2: 2 x1 x2 y1 y2 c,表示询问所有满足格子中数字为c的格子数字 (n,m<=300,Q<=5000) (1&l…