From e0fc4b0cae5a09544caa7fb06231b9029453d3ab Mon Sep 17 00:00:00 2001 From: Taichi Yamakawa Date: Tue, 4 May 2021 18:34:21 +0900 Subject: [PATCH] atcoder/typical90D --- atcoder/typical90/D/main.cpp | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 atcoder/typical90/D/main.cpp diff --git a/atcoder/typical90/D/main.cpp b/atcoder/typical90/D/main.cpp new file mode 100644 index 00000000..4ec8965f --- /dev/null +++ b/atcoder/typical90/D/main.cpp @@ -0,0 +1,49 @@ +#include + +using namespace std; +using ll = int64_t; +using ff = long double; + +int H, W; +vector> A; + +vector> solve() { + vector row_sum(H, 0), col_sum(W, 0); + for (int y = 0; y < H; ++y) { + for (int x = 0; x < W; ++x) { + row_sum[y] += A[y][x]; + col_sum[x] += A[y][x]; + } + } + vector> B(H, vector(W, 0)); + for (int y = 0; y < H; ++y) { + for (int x = 0; x < W; ++x) { + B[y][x] = row_sum[y] + col_sum[x] - A[y][x]; + } + } + return B; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(0); cout.tie(0); + + cin >> H >> W; + A.assign(H, vector(W)); + for (int y = 0; y < H; ++y) { + for (int x = 0; x < W; ++x) { + cin >> A[y][x]; + } + } + + auto B = solve(); + for (int y = 0; y < H; ++y) { + for (int x = 0; x < W; ++x) { + if (x > 0) cout << " "; + cout << B[y][x]; + } + cout << endl; + } + + return 0; +} \ No newline at end of file