Skip to content

Commit 86a155c

Browse files
authored
Merge pull request #411 from xirc/atcoder/typical90D
AtCoder/Typical90D
2 parents 3fca423 + e0fc4b0 commit 86a155c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

atcoder/typical90/D/main.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int H, W;
8+
vector<vector<int>> A;
9+
10+
vector<vector<int>> solve() {
11+
vector<int> row_sum(H, 0), col_sum(W, 0);
12+
for (int y = 0; y < H; ++y) {
13+
for (int x = 0; x < W; ++x) {
14+
row_sum[y] += A[y][x];
15+
col_sum[x] += A[y][x];
16+
}
17+
}
18+
vector<vector<int>> B(H, vector<int>(W, 0));
19+
for (int y = 0; y < H; ++y) {
20+
for (int x = 0; x < W; ++x) {
21+
B[y][x] = row_sum[y] + col_sum[x] - A[y][x];
22+
}
23+
}
24+
return B;
25+
}
26+
27+
int main() {
28+
ios_base::sync_with_stdio(false);
29+
cin.tie(0); cout.tie(0);
30+
31+
cin >> H >> W;
32+
A.assign(H, vector<int>(W));
33+
for (int y = 0; y < H; ++y) {
34+
for (int x = 0; x < W; ++x) {
35+
cin >> A[y][x];
36+
}
37+
}
38+
39+
auto B = solve();
40+
for (int y = 0; y < H; ++y) {
41+
for (int x = 0; x < W; ++x) {
42+
if (x > 0) cout << " ";
43+
cout << B[y][x];
44+
}
45+
cout << endl;
46+
}
47+
48+
return 0;
49+
}

0 commit comments

Comments
 (0)