题意
题目链接
sol
很傻x的题。。
c才100, n, m才300,直接开100个二维树状数组就做完了。。
#include<bits/stdc++.h> using namespace std; const int maxn = 301; inline int read() { char c = getchar(); int x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } int n, m, col[maxn][maxn]; struct bit { #define lb(x) (x & (-x)) int t[maxn][maxn]; void add(int x, int y, int v) { for(int i = x; i <= n; i += lb(i)) for(int j = y; j <= m; j += lb(j)) t[i][j] += v; } int sum(int x, int y) { int ans = 0; for(int i = x; i; i -= lb(i)) for(int j = y; j; j -= lb(j)) ans += t[i][j]; return ans; } int query(int x1, int x2, int y1, int y2) { return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1); } }t[101]; int main() { n = read(); m = read(); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) t[col[i][j] = read()].add(i, j, 1); int q = read(); while(q--) { int opt = read(), a = read(), b = read(), c = read(), d, e; if(opt == 1) t[col[a][b]].add(a, b, -1), t[col[a][b] = c].add(a, b, 1); if(opt == 2) d = read(), e = read(), printf("%dn", t[e].query(a, b, c, d)); } return 0; }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/605325.html