三位树状数组。

/* 3584 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std; #define MAXN 105 bool cnt[MAXN][MAXN][MAXN];
int n, m; inline int lowest(int x) {
return x&-x;
} bool sum(int x, int y, int z) {
int i, j, k;
int ret = ; for (i=x; i; i-=lowest(i)) {
for (j=y; j; j-=lowest(j)) {
for (k=z; k; k-=lowest(k)) {
ret += cnt[i][j][k];
}
}
}
return (ret&) ? true:false;
} void update(int x, int y, int z) {
int i, j, k; for (i=x; i<=n; i+=lowest(i)) {
for (j=y; j<=n; j+=lowest(j)) {
for (k=z; k<=n; k+=lowest(k)) {
cnt[i][j][k] = !cnt[i][j][k];
}
}
}
} int main() {
int i, j, k;
int x1, y1, z1, x2, y2, z2; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif while (scanf("%d %d", &n, &m)!=EOF) {
memset(cnt, false, sizeof(cnt));
while (m--) {
scanf("%d", &i);
if (i) {
scanf("%d%d%d%d%d%d", &x1,&y1,&z1, &x2,&y2,&z2);
update(x1, y1, z1);
update(x1, y1, z2+);
update(x1, y2+, z2+);
update(x1, y2+, z1);
update(x2+, y1, z1);
update(x2+, y1, z2+);
update(x2+, y2+, z2+);
update(x2+, y2+, z1);
} else {
scanf("%d %d %d", &x1, &y1, &z1);
k = sum(x1, y1, z1);
if (k)
puts("");
else
puts("");
}
}
} return ;
}

【HDOJ】3584 Cube的更多相关文章

  1. 【HDOJ】4801 Pocket Cube 的几种解法和优化

    1. 题目描述给定一个$2 \times 2 \times 2$的魔方,当某个面上的4个小块颜色均相同时,称这个面为complete.求对这个魔方进行$n \in [1,7]$次旋转(沿某个面顺时针或 ...

  2. 【HDOJ】3220 Alice’s Cube

    状态压缩+逆向BFS.方向数组就是任意相邻的两点(初始化时减1),每个顶点均有4个相邻点.因此,共有16*4/2=32个方向.按序排列即可找到. /* 3220 */ #include <ios ...

  3. 【HDOJ】3309 Roll The Cube

    BFS,考虑一球进洞仅一球滚动以及两球重叠的情况即可. /* 3309 */ #include <iostream> #include <queue> #include < ...

  4. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  5. 【MCU】【STM32】1.cube MX库使用笔记

    STM32Cube 是一个全面的软件平台,包括了ST产品的每个系列.(如,STM32CubeF4 是针对STM32F4系列). 平台包括了STM32Cube 硬件抽象层和一套的中间件组件(RTOS, ...

  6. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  7. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  8. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

  9. 【HDOJ】【2829】Lawrence

    DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...

随机推荐

  1. php yield

    php中关于 yield 关键字的介绍[点击查看] <?php function gen_one_to_three() { for ($i = 1; $i <= 3; $i++) { // ...

  2. 解锁Scott过程中出现的问题及解决办法

    一.conn sys/sys as sysdba; //以DBA的身份登录 出现以下错误 经查 协议适配器错误的问题的原因有三个 监听服务没有起起来.windows平台个一如下操作:开始---程序-- ...

  3. ADO.Net技术

    Connection对象 1.连接数据库 通过SqlConnection对象的State属性判断数据库的连接状态: public override ConnectionState State{ get ...

  4. CSS权威指南-第三版--读书笔记

    第一章:CSS和文档 html是结构化语言,css是样式语言,html主要用来被强大的搜索引擎更好的索引,更好的让一个盲人通过语音浏览器来了解我们的网页,这也就是为什么说html是结构话语言,因为这是 ...

  5. phpstrtotime()对于31日求上个月有问题

    PHP自带的strtotime()对于31日求上个月有问题,如下: <?php $date = "2012-07-31"; $date_unix = strtotime($d ...

  6. 随便说一说bootstrap-table插件

    如题... bootstrap-table插件是一个js的表格插件 找了一下资料发现并没有多少 这里放一下初始化的语法 这里在html中写一个目标table元素 <table id=" ...

  7. JQuery Datatables(二)

    前篇讲到了Datatables的基本用法,链接地址:http://www.cnblogs.com/wumian1360/p/4263129.html 今天来实现5,6,7三点. 其实Datatable ...

  8. 分享red hat linux 6上安装oracle11g时遇到的gcc: error trying to exec 'cc1': execvp: No such file or directory的问题处理过程

    安装环境:Red Hat Linux 6.5_x64.oracle11g 64bit 报错详情: 安装到68%时弹窗报错: 调用makefile '/test/app/Administrators/p ...

  9. [Twisted] 部署Twisted

    Twisted提供了基础设施,来实现可重用.可配置的方式来部署. 1.Service Twisted使用Service来实现了许多协议,如TCP,FTP,HTTP,SSH等. 实现的IService接 ...

  10. C语言之分配

    #include "stdio.h" void main() { ] = {,,}; *sizeof(int));//malloc calloc relloc arr2[] = ; ...