-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefixArray.cpp
More file actions
executable file
·52 lines (43 loc) · 1.08 KB
/
prefixArray.cpp
File metadata and controls
executable file
·52 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse4")
// #pragma GCC optimize ("unroll-loops")
#define ONLINE_JUDGE freopen("input","r",stdin); freopen("output","w",stdout);
#define MAX 100001
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define hell 1000000007
#define endl '\n'
using namespace std;
int main()
{
ONLINE_JUDGE
int n,m;
cin>>n>>m;
vector<vector<int>>A(n,vector<int>(m));
for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>A[i][j];
int B[n][m];
for(int i=n-1;i>0;i--)
{
for(int j=m-1;j>0;j--)
{
B[i][j] = A[i][j] - A[i-1][j] - A[i][j-1] + A[i-1][j-1];
}
}
for(int i=m-1;i>0;i--) B[0][i] = A[0][i] - A[0][i-1];
for(int i=n-1;i>0;i--) B[i][0] = A[i][0] - A[i-1][0];
B[0][0] = A[0][0];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<B[i][j]<<" ";
cout<<endl;
}
}