题目连接
https://www.acwing.com/problem/content/800/
思路差分矩阵注意的是在构造差分矩阵的时候不是一维的和前一个数相减,而是看作一个小矩阵进行操作
代码#include
using namespace std;
#define ll long long
#define mod 1000000009
#define endl "\n"
#define PII pair
ll ksm(ll a,ll b) {
ll ans = 1;
for(;b;b>>=1LL) {
if(b & 1) ans = ans * a % mod;
a = a * a % mod;
}
return ans;
}
ll lowbit(ll x){return -x & x;}
const int N = 1e3+10;
int n,m,q,a[N][N],d[N][N];
void insert(int x1,int y1,int x2,int y2,int c){
d[x1][y1] += c;
d[x2 + 1][y1] -= c;
d[x1][y2 + 1] -= c;
d[x2 + 1][y2 + 1] += c;
}
int main()
{
cin>>n>>m>>q;
for(int i = 1;i a[i][j];
}
}
for(int i = 1;i x1>>y1>>x2>>y2>>c;
insert(x1,y1,x2,y2,c);
}
ll res = 0;
for(int i = 1;i
关注
打赏