您当前的位置: 首页 >  矩阵

MangataTS

暂无认证

  • 0浏览

    0关注

    423博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

AcWing 798. 差分矩阵

MangataTS 发布时间:2022-01-20 12:34:27 ,浏览量:0

题目连接

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             
关注
打赏
1665836431
查看更多评论
0.0360s