题目

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. 虹软2.0 免费人脸识别C#类库分享

    目前只封装了人脸检测部分的类库,供大家交流学习,肯定有问题,希望大家在阅读使用的时候及时反馈,谢谢!使用虹软技术开发完成 戳这里下载SDKgithub:https://github.com/dayAn ...

  2. ssh REMOTE HOST IDENTIFICATION HAS CHANGED!

    连接到docker的时候,有时因为image重新buid过,就提示 It is also possible that a host key has just been changed. 不让连接. 解 ...

  3. Windows上搭建Flume运行环境

    1.如果没有安装过Java环境,则需首先安装JDK. 可参考<Windows上搭建Kafka运行环境>中的搭建环境安装JDK部分 2.官方下载Flume(当前为apache-flume-1 ...

  4. 用原生js来处理跨域的数据(jsonp)

    说明总结: 1.ajax和jsonp其实本质上是不同的东西.ajax的核心是通过XmlHttpRequest获取非本页内容,而jsonp的核心则是动态添加<script>标签来调用服务器提 ...

  5. Lab 3-4

    Analyze the malware found in the file Lab03-04.exe using basic dynamic analysis tools. (This program ...

  6. android -------- ConstraintLayout 宽高比和偏移量比(三)

    前面的文章 ConstraintLayout 介绍 (一) ConstraintLayout约束属性 (二) 此博文主要讲解: app:layout_constraintHorizontal_bias ...

  7. android -------- Data Binding的使用(三)Observable

    解决:databinding 中 ViewModel数据发生改变,View中也要改变(实时更新) BaseObservable 在ViewModel 中可以继承 BaseObservable publ ...

  8. Tensor RT使用记录

    Tensor RT的介绍在此不做赘述. 自己在服务器上本打算装Tensor RT来着,不过过程很艰辛,最后发现服务器的cudnn版本偏低了,还需要升级cudnn的版本.故,在自己的电脑上了装了下Ten ...

  9. day1-6 字符串、列表、元组、字典、类型转换

    day1 1.python历史. 宏观上:python2 与 python3 区别: python2 源码不标准,混乱,重复代码太多, python3 统一 标准,去除重复代码. 2.python的环 ...

  10. Vrrp和Hsrp的区别

    VRRP原理协议简述简单来说,VRRP是一种容错协议,它为具有组播或广播能力的局域网(如以太网)设计,它保证当局域网内主机的下一跳路由器出现故障时,可以及时的由另一台路由器来代替,从而保持通讯的连续性 ...