#c22704. 二维差分
二维差分
2D Difference Array
Problem Description
You are given an matrix and update operations.
Initially all positions are . Each update gives five numbers and adds to every with and .
Compute the value of the whole matrix after all operations.
Input Format
The first line contains six integers (, , ).
To avoid overly large input, the queries are generated by the following code.
int n, m, q;
unsigned int A, B, C;
unsigned int 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 <= q; i++) {
int x1 = rng61() % n + 1, x2 = rng61() % n + 1;
int y1 = rng61() % m + 1, y2 = rng61() % m + 1;
unsigned int d = rng61();
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
// perform the update operation
}
}
Output Format
To avoid overly large output, output the XOR sum of all numbers in the matrix after all operations.
Sample Input
5 5 10 1 2 3
Sample Output
3809069637