|
| 1 | +//Author: Fuadul Hasan([email protected]) |
| 2 | +//BSMRSTU,Gopalganj |
| 3 | +//#include<bits/stdc++.h> |
| 4 | +#define _USE_MATH_DEFINES |
| 5 | +#include <set> |
| 6 | +#include <map> |
| 7 | +#include <list> |
| 8 | +#include <queue> |
| 9 | +#include <stack> |
| 10 | +#include <cmath> |
| 11 | +#include <ctime> |
| 12 | +#include <cstdio> |
| 13 | +#include <string> |
| 14 | +#include <vector> |
| 15 | +#include <bitset> |
| 16 | +#include <random> |
| 17 | +#include<iomanip> |
| 18 | +#include <cassert> |
| 19 | +#include <cstring> |
| 20 | +#include <sstream> |
| 21 | +#include <complex> |
| 22 | +#include <numeric> |
| 23 | +#include <iostream> |
| 24 | +#include <algorithm> |
| 25 | +#include <functional> |
| 26 | +#include <unordered_set> |
| 27 | +#include <unordered_map> |
| 28 | +using namespace std; |
| 29 | + |
| 30 | +//debug.......... |
| 31 | +#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;} |
| 32 | +vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {} |
| 33 | +template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);} |
| 34 | + |
| 35 | +//............ignore it..................// |
| 36 | +#define F first |
| 37 | +#define S second |
| 38 | +#define Pi atan(1)*4 |
| 39 | +#define mp make_pair |
| 40 | +#define pb push_back |
| 41 | +const int M = 1e9 + 7; |
| 42 | +#define ld long double |
| 43 | +#define ll long long int |
| 44 | +#define happy cin.tie(0); |
| 45 | +#define point(x) cout<<fixed<<setprecision(x) |
| 46 | +int length(string s){return (int)s.size();} |
| 47 | +#define mem(a) memset(a , 0 ,sizeof a) |
| 48 | +#define memn(a) memset(a , -1 ,sizeof a) |
| 49 | +#define coding ios::sync_with_stdio(false); |
| 50 | +#define Unique(c) (c).resize(unique(all(c))-(c).begin()) |
| 51 | +#define vout(v) for (auto z: v) cout << z << " "; cout << endl; |
| 52 | + |
| 53 | +int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;} |
| 54 | +int dx[8]= {1,0,-1,0,-1,-1,1,1}; |
| 55 | +int dy[8]= {0,1,0,-1,-1,1,-1,1}; |
| 56 | + |
| 57 | +#define rep(i,b,e) for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e)) ; i += 1 - 2 * ((b) > (e))) |
| 58 | + |
| 59 | +long long Inv_pow(long long a,long long n){ll res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;} |
| 60 | +template <typename T> vector<T> readVector(int n) {vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; } |
| 61 | +// suffix_prefix.... |
| 62 | +std::vector<ll> prefix_sum(std::vector<ll> a){int n = a.size();std::vector<ll> prf(n,0);for(int i=0;i<n;i++){ |
| 63 | +if(i == 0){prf[i] = a[i];}else{prf[i] = prf[i-1]+a[i];}}return prf;} |
| 64 | +std::vector<ll> suffix_sum(std::vector<ll> a){int n = a.size();std::vector<ll>suf(n,0);for(int i=n-1;i>=0;i--){ |
| 65 | +if(i == n-1){suf[i] = a[i];}else{suf[i] = suf[i+1]+a[i];}}return suf;} |
| 66 | + |
| 67 | +long long Lcm(long long a,long long b){return (((a)*(b)))/__gcd(a,b);} |
| 68 | + |
| 69 | +#define Test cout<<"Case #"<<tc++<<": "; |
| 70 | +int tc = 1; |
| 71 | + |
| 72 | +inline void read(std::vector<int> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}} |
| 73 | +inline void readl(std::vector<ll> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}} |
| 74 | + |
| 75 | +template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } |
| 76 | +template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } |
| 77 | + |
| 78 | +inline void read(int v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}} |
| 79 | +inline void readl(ll v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}} |
| 80 | + |
| 81 | +inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;} |
| 82 | +inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;} |
| 83 | +inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;} |
| 84 | + |
| 85 | +#define pr pair<int, int> |
| 86 | +#define vpr vector<pr> |
| 87 | +#define vi std::vector<int> |
| 88 | +#define vll std::vector<ll> |
| 89 | +#define all(n) n.begin(),n.end() |
| 90 | + |
| 91 | + |
| 92 | +const int Inf = (int)2e9 + 5; |
| 93 | +const ll Lnf = (ll)2e18 + 5; |
| 94 | +const int N = 5e5 + 5; |
| 95 | +const int NN = 1e6 + 5; |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +int solve() |
| 100 | +{ |
| 101 | + |
| 102 | + //Test |
| 103 | + |
| 104 | + int n,m; |
| 105 | + cin>>n>>m; |
| 106 | + |
| 107 | + vector<vector<int>>v(n+2, vector<int> (m+2,0)); |
| 108 | + |
| 109 | + int q; |
| 110 | + cin>>q; |
| 111 | + int x1,x2,y1,y2,k; |
| 112 | + |
| 113 | + while(q--){ |
| 114 | + cin>>x1>>y1>>x2>>y2>>k; |
| 115 | + v[x1][y1] += k; |
| 116 | + v[x1][y2+1] -= k; |
| 117 | + v[x2+1][y1] -= k; |
| 118 | + v[x2+1][y2+1] += k; |
| 119 | + } |
| 120 | + |
| 121 | + for(int i=1;i<=n;i++){ |
| 122 | + for(int j=1;j<=m;j++){ |
| 123 | + v[i][j] += v[i-1][j]+v[i][j-1]-v[i-1][j-1]; |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + for(int i=1;i<=n;i++){ |
| 128 | + for(int j=1;j<=m;j++){ |
| 129 | + cout<<v[i][j]<<" "; |
| 130 | + }cout<<endl; |
| 131 | + } |
| 132 | + |
| 133 | + return 0; |
| 134 | + //error(); |
| 135 | +} |
| 136 | +int main(){ |
| 137 | + |
| 138 | + happy coding |
| 139 | + int test = 1; |
| 140 | + //cin>>test; |
| 141 | + while (test--)solve();return 0; |
| 142 | +} |
| 143 | + |
| 144 | +/* |
| 145 | +1. Everything happens for something good. |
| 146 | +2. Don't expect anything from anyone except yourself. |
| 147 | +3. Self discipline is the magic power that makes you unstoppable. |
| 148 | +*/ |
| 149 | + |
| 150 | +/* Note: |
| 151 | +-> when you use long long. always keep ll in integer number. like 2LL or (ll)i. |
| 152 | +*/ |
0 commit comments