CodeForces 341DIahub and Xors(二维树状数组)
来源:互联网 发布:plsql导出sql乱码 编辑:程序博客网 时间:2024/05/17 22:52
思路:典型的二维异或树状数组,有一个结论是在x位置放置了一个元素,只会对x+2,x+4等位置产生影响
#include<bits/stdc++.h>using namespace std;#define LL long longconst int maxn = 1005;LL lowbit(LL x){return x&(-x);}LL c[2][2][maxn][maxn];int n,m;void update(int x1,int y1,LL v){ for(int i = x1;i<=maxn;i+=lowbit(i))for(int j = y1;j<=maxn;j+=lowbit(j))c[x1&1][y1&1][i][j]^=v;}LL query(int x1,int y1){LL ans = 0;for(int i=x1;i;i-=lowbit(i))for(int j = y1;j;j-=lowbit(j))ans^=c[x1&1][y1&1][i][j];return ans;}int main(){ scanf("%d%d",&n,&m);for(int i = 1;i<=m;i++){ int op,x1,y1,x2,y2;scanf("%d%d%d%d%d",&op,&x1,&y1,&x2,&y2);if(op==1){LL ans = 0;ans^=query(x1-1,y1-1);ans^=query(x1-1,y2);ans^=query(x2,y1-1);ans^=query(x2,y2); printf("%lld\n",ans);}else{LL v; scanf("%lld",&v);update(x1,y1,v);update(x1,y2+1,v);update(x2+1,y1,v);update(x2+1,y2+1,v);} }}
0 0
- CodeForces 341DIahub and Xors(二维树状数组)
- [Codeforces 341D] Iahub and Xors (二维树状数组)
- CF 341D - Iahub and Xors(二维树状数组)
- 【树状数组】[CodeForces - 341D]Iahub and Xors
- [CodeForces 677D] Vanya and Treasure (二维树状数组+静态前缀最小值)
- Codeforces 707E Garlands(二维树状数组)
- codeforces--707E. Garlands(二维树状数组)
- 树状数组(二维)
- HDU 5465 Clarke and puzzle(二维树状数组)
- [二维树状数组] codeforces 707E. Garlands
- codeforces 869E(哈希&二维树状数组)
- Codeforces 387E George and Cards(二分+树状数组)
- CodeForces 658B Bear and Displayed Friends(树状数组)
- poj1195(二维树状数组)
- poj2155(二维树状数组)
- poj1195 (二维树状数组)
- HLJUOJ1118(二维树状数组)
- POJ_1195 (二维树状数组)
- Android中的so注入(inject)和挂钩(hook) - For both x86 and arm
- 用matlab实现图片的缩放
- 将bitmap文件拖进对话框中,获取位图文件的参数。
- Java GUI之初见JProgressBar
- Android单元测试
- CodeForces 341DIahub and Xors(二维树状数组)
- oracle数据库常用SQL
- 开发需求修改梳理
- JMS
- 整型转字符型
- 微信小程序
- 小C语言--词法分析程序
- RN混合开发坑1-版本问题
- HTML 为select自定义出现滚动条的条数