Loading... ``` #include <iostream> using namespace std; const int N = 1e3 + 10; int n, m, q, x1, y1, x2, y2, c, arr[N][N]; inline void push(const int& x1, const int& y1, const int& x2, const int& y2) { arr[x1][y1] += c; arr[x2 + 1][y2 + 1] += c; arr[x2 + 1][y1] -= c; arr[x1][y2 + 1] -= c; } int main () { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> q; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { cin >> c; push(i,j,i,j); } while(q--) { cin >> x1 >> y1 >> x2 >> y2 >> c; push(x1,y1,x2,y2); } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { arr[i][j] += arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1]; cout << arr[i][j] << ' '; } cout << '\n'; } return 0; } ``` 最后修改:2024 年 08 月 08 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏