#c22703. 二维前缀和
二维前缀和
2D Prefix Sum
Problem Description
You are given an matrix and queries.
Each query gives four numbers and asks for the value of .
Input Format
The first line contains six integers ($1 \leq n, m \leq 2 \times 10^3, 1 \le q \leq 10^6, 0 \leq A, B, C < 2^{32}$).
To avoid overly large input, and the queries are generated by the following code.
int n, m, q;
unsigned int A, B, C;
long long a[N][N];
inline unsigned int rng61() {
A ^= A << 16;
A ^= A >> 5;
A ^= A << 1;
unsigned int t = A;
A = B;
B = C;
C ^= t ^ A;
return C;
}
int main(){
scanf("%d%d%d%u%u%u", &n, &m, &q, &A, &B, &C);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
a[i][j] = rng61();
}
}
for (int i = 1; i <= q; i++) {
int x1 = rng61() % n + 1, x2 = rng61() % n + 1;
int y1 = rng61() % m + 1, y2 = rng61() % m + 1;
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
// perform the query
}
}
Output Format
To avoid overly large output, output the XOR sum of all query answers.
Sample Input
5 5 10 1 2 3
Sample Output
1655687751