题目链接 裸二维树状数组 #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;…
题目描述 输入 输出 样例输入 样例输出 1 2 题解 二维树状数组 一开始没看到 1≤c≤100 ,想到了主X树和X块,结果发现c的范围那么小... 二维树状数组水题,和一维的一样,向上修改,向下查询,把一个范围变为4个范围处理. #include <cstdio> int a[310][310] , f[110][310][310] , n , m; void update(int p , int x , int y , int a) { int i , j; for(i = x ; i…
大水题. 建立100个二维树状数组,总复杂度就是O(qlognlogm). # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # include <queue> # include <stack> # include <map> # include <set&…
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…