0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00
Baoshuo Ren 2021-12-01 19:17:27 +08:00
parent 14308b5cfd
commit ce05e9d4dd
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

36
AcWing/798/798.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int n, m, q, c, b[1005][1005];
int main() {
cin >> n >> m >> q;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> c;
b[i][j] += c;
b[i + 1][j] -= c;
b[i][j + 1] -= c;
b[i + 1][j + 1] += c;
}
}
while (q--) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2 >> c;
b[x1][y1] += c;
b[x2 + 1][y1] -= c;
b[x1][y2 + 1] -= c;
b[x2 + 1][y2 + 1] += c;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
cout << b[i][j] << ' ';
}
cout << endl;
}
return 0;
}