题目

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=996

题意

被射击掉了一些列的魔方。组成模仿的每个方块的六个面颜色相同。给六个面的视图,求魔方最多还剩下多少个小块。

魔方最多十阶。

思路

关键在于将视图的坐标(加上视图深度)映射为三维坐标系内的坐标,之后就可以不断删除会造成矛盾的暴露在表面的方块,直到没有方块或者没有矛盾为止。

感想

1. 注意<写成了>=

2. 忘记了检测当前方块是否已经删除过了。

3. 忘了memset

4. 视图的映射有价值,不过需要注意坐标系建立不同

代码

Runtime: 0.006

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <tuple>
#include <cassert> using namespace std;
#define LOCAL_DEBUG
const int MAXN = ; int n;
bool del[MAXN][MAXN][MAXN];
char color[MAXN][MAXN][MAXN];
char fc[][MAXN][MAXN];
int deep[][MAXN][MAXN];
int facec[];
int polarc[]; char statusDescribe[][] = {
"YXZ",
"ZXy",
"yXz",
"zXY",
"YZx",
"YzX"
}; int getAns() {
int ans = ;
for (int i = ; i < n; i++) {
for (int j = ; j < n; j++) {
for (int k = ; k < n; k++) {
if (!del[i][j][k])ans++;
}
}
}
return ans;
} void face2polar(int fid, int facec[], int polarc[]) {
for (int i = ; i < ; i++) {
char sta = statusDescribe[fid][i];
if (sta >= 'X' && sta <= 'Z') {
polarc[i] = facec[sta - 'X'];
}
else {
polarc[i] = n - - facec[sta - 'x'];
}
}
} void polar2face(int fid, int facec[], int polarc[]) {
for (int i = ; i < ; i++) {
char sta = statusDescribe[fid][i];
if (sta >= 'X' && sta <= 'Z') {
facec[sta - 'X'] = polarc[i];
}
else {
facec[sta - 'x'] = n - - polarc[i];
}
}
} int main() {
#ifdef LOCAL_DEBUG
freopen("input.txt", "r", stdin);
//freopen("output2.txt", "w", stdout);
#endif // LOCAL_DEBUG
for (int ti = ; scanf("%d", &n) == && n; ti++) {
memset(del, , sizeof(del));
memset(color, , sizeof(color));
memset(fc, , sizeof(fc));
memset(deep, , sizeof(deep));
memset(facec, , sizeof(facec));
memset(polarc, , sizeof(polarc));
char buff[];
cin.getline(buff, );
for(int i = ; i < n;i++){
cin.getline(buff, );
for (int k = ; k < ; k++) {
for (int j = ; j < n; j++) {
fc[k][i][j] = buff[(n + ) * k + j];
}
}
} int &x = facec[];
int &y = facec[];
int &z = facec[];
int &a = polarc[];
int &b = polarc[];
int &c = polarc[];
for (int fid = ; fid < ; fid++) {
for (x = ; x < n; x++) {
for (y = ; y < n; y++) {
if (fc[fid][x][y] == '.') {
deep[fid][x][y] = n;
for (z = ; z < n; z++) {
face2polar(fid, facec, polarc);
// printf("R: %d, del %d-(%d, %d, %d) : (%d, %d, %d)\n", getAns(), fid, x, y, z, a, b, c);
del[a][b][c] = true;
}
}
}
}
}
bool checkFlag = true;
while (checkFlag) {
checkFlag = false;
for (int fid = ; fid < ; fid++) {
for (x = ; x < n; x++) {
for (y = ; y < n; y++) {
for (z = deep[fid][x][y]; z < n; z++, deep[fid][x][y]++) {
face2polar(fid, facec, polarc);
if (del[a][b][c])continue;
else if (color[a][b][c] == || color[a][b][c] == fc[fid][x][y]) {
color[a][b][c] = fc[fid][x][y];
break;
}
else{
del[a][b][c] = true;
checkFlag = true;
}
}
}
}
}
}
int ans = getAns();
printf("Maximum weight: %d gram(s)\n", ans);
} return ;
}

Uva LV 2995 Image Is Everything 模拟,坐标映射,视图映射 难度: 1的更多相关文章

  1. uva 210 - Concurrency Simulator (并行程序模拟)

    from CSDN: https://blog.csdn.net/su_cicada/article/details/87898579 例题6-1 并行程序模拟( Concurrency Simula ...

  2. uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列

    题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...

  3. UVA 1030 - Image Is Everything【模拟+思维+迭代更新】

    题目链接:uva 1030 - Image Is Everything 题目大意:有一个最大为n*n*n的立方体的一个不规整立体,由若干个1*1*1的小正方体构成(每一个小正方体被涂成不同的颜色),给 ...

  4. UVA 10881 - Piotr's Ants【模拟+思维】

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  5. 【UVA】1596 Bug Hunt(模拟)

    题目 题目     分析 算是个模拟吧     代码 #include <bits/stdc++.h> using namespace std; map<int,int> a[ ...

  6. UVA 1604:Cubic Eight-Puzzle(模拟,BFS Grade C)

    题意: 3*3方格,有一个是空的.其他的每个格子里有一个立方体.立方体最初上下白色,前后红色,左右蓝色.移动的方式为滚.给出初态空的位置,终态上面颜色情况,问最少多少步能到达.如果超过30步不能到达, ...

  7. ACM学习历程——UVA 127 "Accordian" Patience(栈;模拟)

    Description  ``Accordian'' Patience  You are to simulate the playing of games of ``Accordian'' patie ...

  8. UVA - 11954 Very Simple Calculator 【模拟】

    题意 模拟二进制数字的位运算 思路 手写 位运算函数 要注意几个坑点 一元运算符的优先级 大于 二元 一元运算符 运算的时候 要取消前导0 二元运算符 运算的时候 要将两个数字 数位补齐 输出的时候 ...

  9. UVA 1596 Bug Hunt (大模拟 栈)

    题意: 输入并模拟执行一段程序,输出第一个bug所在的行. 每行程序有两种可能: 数组定义: 格式为arr[size]. 例如a[10]或者b[5],可用下标分别是0-9和0-4.定义之后所有元素均为 ...

随机推荐

  1. openstack环境搭建常用命令

    1,编辑/etc/selinux/config文件,关闭selinux SELINUX=disabled 2,清空iptables规则并保存 # iptables -F # service iptab ...

  2. JavaScript中的prototype和__proto__细致解析

    最近在学js,体会了一点点它的灵活性.对于初学者的我,总是被它的灵活感到晕头转向,最近发现了一点东西想与大家分享. JavaScript中的prototype和_proto_: 我们先了解一点js中的 ...

  3. Python 百分比计算

    遇到计算百分比的情况,查了一下,有两种方式 具体实现方式见下面代码 # 方式1 格式化为float ,然后 处理成%格式, 需要对分子/分母 * 100如下, percentList.append(' ...

  4. Java访问ActiveMQ

    1.下载安装ActiveMQ 下载可以去官网下载:http://activemq.apache.org/download.html.我们这里使用windows测试,所以下载windows版本即可. 2 ...

  5. mongodb分享(二)

    上次讲的:查询find\findone\pretty.条件操作符 (大于.小于.大于等于.小于等于.不等于,$type).limit\skip.sort.Db.postjson.getIndexes( ...

  6. springboot---->错误: 找不到或无法加载主类

    刚开始是往上面箭头指出的方向去找问题的原因,但是试了各种方法后问题还是没有解决,于是乎我把焦点转去查看eclipsede控制台处: 主要的错误提示如下: Archive for required li ...

  7. Python如何发布程序

    https://blog.csdn.net/wem603947175/article/details/81589729

  8. Shell脚本字体颜色

    [root@web01 scripts]# man console_codesecho -e "\033[背景颜色:字体颜色m字符串\033[0m",例:echo -e " ...

  9. Practical Node.js (2018版) 第5章:数据库 使用MongoDB和Mongoose,或者node.js的native驱动。

    Persistence with MongoDB and Mongoose https://github.com/azat-co/practicalnode/blob/master/chapter5/ ...

  10. 新项目的vue组件

    项目地址:http://pan.baidu.com/s/1qYIxCXu 很久没有写博客的原因的是之前一直在解决一个问题,这个问题就是:我们在写组件的时候,官方推荐把css写在组件里面,但是如果我们写 ...