http://acm.hdu.edu.cn/showproblem.php?pid=3584
来源:互联网 发布:西安行知中学怎么分班 编辑:程序博客网 时间:2024/06/03 12:58
三维树状数组的一个模板题。。应该是属于插线问点这一类型的。。。
题意:一开始三维数组的元素都为0,当输入操作为1时把1->0或者0->1..问经过许多次操作后该位置是1还是0,。
#include<iostream>#include<cstdio>#include<string.h>#include<algorithm>#include<assert.h>#define N 101using namespace std;int s[N][N][N];int lowbit(int x){return x&(-x);}void update(int x,int y,int z){ for(int i=x;i<N;i+=lowbit(i)) for(int j=y;j<N;j+=lowbit(j)) for(int k=z;k<N;k+=lowbit(k)) s[i][j][k]++;}int Quary(int x,int y,int z){ int sum=0; for(int i=x;i>0;i-=lowbit(i)) for(int j=y;j>0;j-=lowbit(j)) for(int k=z;k>0; k-=lowbit(k))sum+=s[i][j][k]; return sum; }int main(){ int n,m; while(~scanf("%d%d",&n,&m)) { int flag; int x1,y1,z1,x2,y2,z2; memset(s,0,sizeof(s)); while(m--) { scanf("%d",&flag); if(flag==0) { scanf("%d%d%d",&x1,&y1,&z1); printf("%d\n",Quary(x1,y1,z1)%2); } else { scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2); update(x1,y1,z1);update(x1,y1,z2+1);update(x1,y2+1,z1);update(x1,y2+1,z2+1);update(x2+1,y1,z1);update(x2+1,y2+1,z1);update(x2+1,y1,z2+1);update(x2+1,y2+1,z2+1); } } }return 0;}
- http://acm.hdu.edu.cn/showproblem.php?pid=3584
- http://acm.hdu.edu.cn/showproblem.php?pid=1005
- http://acm.hdu.edu.cn/showproblem.php?pid=1333
- http://acm.hdu.edu.cn/showproblem.php?pid=2710
- http://acm.hdu.edu.cn/showproblem.php?pid=2866
- http://acm.hdu.edu.cn/showproblem.php?pid=1041
- http://acm.hdu.edu.cn/showproblem.php?pid=1719
- http://acm.hdu.edu.cn/showproblem.php?pid=2136
- http://acm.hdu.edu.cn/showproblem.php?pid=1166
- http://acm.hdu.edu.cn/showproblem.php?pid=3519
- http://acm.hdu.edu.cn/showproblem.php?pid=2446
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1874
- http://acm.hdu.edu.cn/showproblem.php?pid=1863
- http://acm.hdu.edu.cn/showproblem.php?pid=1879
- http://acm.hdu.edu.cn/showproblem.php?pid=1875
- http://acm.hdu.edu.cn/showproblem.php?pid=1102
- http://acm.hdu.edu.cn/showproblem.php?pid=1162
- 收缩菜单
- 第13周报告2
- 节点流和处理流
- Android应用开发之编码实现 软件界面
- 在SVN中偷偷发个LGame的C# Beta版(意味着支持WP7和XBOX之类了)
- http://acm.hdu.edu.cn/showproblem.php?pid=3584
- GCC常用命令
- 将数据库内表中的数据导出到txt文档中,并且显示一个对话框,提示用户保存文件的位置
- 第13周报告3
- 原创:字符串和语句逆转的几种方式,可以任意组合,java实现
- hash索引和btree索引的区别
- xp账户被锁定
- 实习仨月有感
- WINCE日文系统路径中\变成人民币符号¥的问题