From ce05e9d4dd24992546cda7e9966c1b55fc3f56e8 Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Wed, 1 Dec 2021 19:17:27 +0800 Subject: [PATCH] =?UTF-8?q?798.=20=E5=B7=AE=E5=88=86=E7=9F=A9=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/9152970/ --- AcWing/798/798.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 AcWing/798/798.cpp diff --git a/AcWing/798/798.cpp b/AcWing/798/798.cpp new file mode 100644 index 00000000..0aef6fe5 --- /dev/null +++ b/AcWing/798/798.cpp @@ -0,0 +1,36 @@ +#include + +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; +}