HDU 3584 Cube --三维树状数组】的更多相关文章

题意:给一个三维数组n*n*n,初始都为0,每次有两个操作: 1. 翻转(x1,y1,z1) -> (x2,y2,z2) 0. 查询A[x][y][z] (A为该数组) 解法:树状数组维护操作次数,一个数被操作偶数次则相当于没被操作. 每次更新时在8个位置更新: .相当于8个二进制数:000,001,010,011,100,101,110,111. (我是由二维推过来的) 其实不用有的为-1,直接1也行,因为反正会改变奇偶性. 代码: #include <iostream> #inclu…
HDU - 3584 Cube Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. I…
Problem Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. Initially we have A[i, j, k] = 0 (1 <= i, j, k <= N). We define two operations, 1: "Not"…
题意:还是那篇论文里面讲到的,三维树状数组http://wenku.baidu.com/view/1e51750abb68a98271fefaa8画个立方体出来对照一下好想一点 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #inclu…
三维树状数组模版.优化不动了. #include <set> #include <map> #include <stack> #include <cmath> #include <queue> #include <cstdio> #include <string> #include <vector> #include <iomanip> #include <cstring> #inclu…
1470 最简单的三维树状数组 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> using namespace std; #define lowbit(x) x&(-x) ][][],n; int getsum(int x,int y,int z) { ,i,j,g; ; i -= lowbit(i)…
涉及的知识点挺多,但是大多是套路 1.求曼哈顿距离的最值一般对所有情况进行讨论 2.三维树状数组用来求前缀最大值 /* 有一个三维坐标系(x,y,z),取值范围为[1,n],[1,m],[1,h],有两种操作 1.在三维坐标系上更新一个点(x1,y1,z1) 2.给定一个点(x2,y2,z2),问在坐标系上离该点Manhattan距离最短的点 即最小的 |x2-x1|+|y2-y1|+|z2-z1| 令 f=|x2-x1|+|y2-y1|+|z2-z1|,那么可以讨论去绝对值后f的八种情况 f0…
HDU 3333:http://acm.hdu.edu.cn/showproblem.php?pid=3333 这两个题是类似的,都是离线处理查询,对每次查询的区间的右端点进行排序.这里我们需要离散化处理一下,标记一下前面是否出现过这个值,然后不断更新last数组(该数组保存的是每个数最后一次出现的位置).最后用树状数组维护. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; ; struct node{…
题意:给一个数组,每次查询输出区间内不重复数字的和. 这是3xian教主的题. 用前缀和的思想可以轻易求得区间的和,但是对于重复数字这点很难处理.在线很难下手,考虑离线处理. 将所有查询区间从右端点由小到大排序,遍历数组中的每个数字,每次将该数字上次出现位置的值在树状数组中改为0,再记录当前位置,在树状数组中修改为当前的数值.这样可以保证在接下来的查询中该数字只出现了一次.这是贪心的思想,只保留最可能被以后区间查询的位置.如果当前位置是某个查询区间的右端点,这时候就可以查询了.最后再根据查询区间…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3333 题意就是询问区间不同数字的和. 比较经典的树状数组应用. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #inc…