B3693 学习笔记

省流:干脆叫【模板】二维前缀和算了。

题目传送门

一眼:询问+矩阵求和

二维前缀和维护不就行了吗??

第一次讲黄题,觉得有那么亿点点弱智

直接上代码。

(远古代码,没有猎奇火车头)

code
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // 这个不加速也会寄
#define int unsigned long long // 十年 OI 一场空,不开 ull 见祖宗
using namespace std;
int s[1005][1005], u, v, x, y, ans, n, m, q, t, k;
signed main() {
    fast;
	cin >> t;
	while (t--){
		memset (s, 0, sizeof (s));
		cin >> n >> m >> q;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++){
				cin >> k;
				s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + k;
			}
		ans = 0;
		while (q--){
			cin >> u >> v >> x >> y;
			ans ^= (s[x][y] - s[x][v - 1] - s[u - 1][y] + s[u - 1][v - 1]);
		}
		cout << ans << endl;
	}
	return 0;
}
posted @ 2026-02-12 13:33  constexpr_ll  阅读(3)  评论(0)    收藏  举报