大水题. 建立100个二维树状数组,总复杂度就是O(qlognlogm). # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # include <queue> # include <stack> # include <map> # include <set&…
题目描述 输入 输出 样例输入 样例输出 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…
题目链接 裸二维树状数组 #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;…