#include<bits/stdc++.h> using namespace std; int a[1001][1001],b[1001][1001],n,m,q,sx1,sx2,c,sy2,sy1; //1 2 2 1 |1 1 0 -1|1 2 2 1 //3 2 2 1 |2 -2 0 0 |3 2 //1 1 1 1 |-2 1 0 1 | //H=D-(B+C-A) //A B E F //C D G H int main(){ cin>>n>>m>>q; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>a[i][j]; b[i][j]=a[i][j]-(a[i-1][j]+a[i][j-1]-a[i-1][j-1]); } } while(q--){ cin>>sx1>>sy1>>sx2>>sy2>>c; b[sx1][sy1]+=c; b[sx1][sy2+1]-=c; b[sx2+1][sy1]-=c; b[sx2+1][sy2+1]+=c; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ a[i][j]=b[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1]; cout<<a[i][j]<<" "; } cout<<endl; } return 0; } /************************************************************** Problem: 2351 User: chenpengxi Language: C++ Result: Accepted Time:4 ms Memory:9900 kb ****************************************************************/