Uva LV 2995 Image Is Everything 模拟,坐标映射,视图映射 难度: 1
题目
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的更多相关文章
- uva 210 - Concurrency Simulator (并行程序模拟)
from CSDN: https://blog.csdn.net/su_cicada/article/details/87898579 例题6-1 并行程序模拟( Concurrency Simula ...
- uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列
题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...
- UVA 1030 - Image Is Everything【模拟+思维+迭代更新】
题目链接:uva 1030 - Image Is Everything 题目大意:有一个最大为n*n*n的立方体的一个不规整立体,由若干个1*1*1的小正方体构成(每一个小正方体被涂成不同的颜色),给 ...
- UVA 10881 - Piotr's Ants【模拟+思维】
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 【UVA】1596 Bug Hunt(模拟)
题目 题目 分析 算是个模拟吧 代码 #include <bits/stdc++.h> using namespace std; map<int,int> a[ ...
- UVA 1604:Cubic Eight-Puzzle(模拟,BFS Grade C)
题意: 3*3方格,有一个是空的.其他的每个格子里有一个立方体.立方体最初上下白色,前后红色,左右蓝色.移动的方式为滚.给出初态空的位置,终态上面颜色情况,问最少多少步能到达.如果超过30步不能到达, ...
- ACM学习历程——UVA 127 "Accordian" Patience(栈;模拟)
Description ``Accordian'' Patience You are to simulate the playing of games of ``Accordian'' patie ...
- UVA - 11954 Very Simple Calculator 【模拟】
题意 模拟二进制数字的位运算 思路 手写 位运算函数 要注意几个坑点 一元运算符的优先级 大于 二元 一元运算符 运算的时候 要取消前导0 二元运算符 运算的时候 要将两个数字 数位补齐 输出的时候 ...
- UVA 1596 Bug Hunt (大模拟 栈)
题意: 输入并模拟执行一段程序,输出第一个bug所在的行. 每行程序有两种可能: 数组定义: 格式为arr[size]. 例如a[10]或者b[5],可用下标分别是0-9和0-4.定义之后所有元素均为 ...
随机推荐
- pipenv安装.whl
windows下很多库安装不方便,主要是编译C之类的. 之前这样做: 1去https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载各种版本编译好的.whl 2 pi ...
- top 命令常用操作
1.显示进程参数 top -c 下面操作为top命令后操作 2.按cpu/mem排序 shift + p/m 3.高亮 排序列 按x键 4.高亮 变化进程行 按b键 5.显示cpu每核的运行状态 按1 ...
- C# 中 ? 和 ??
a??2 等价于 a==null?2:a 原文:https://blog.csdn.net/szx1999/article/details/50996495
- 第 8 章 容器网络 - 053 - overlay 是如何隔离的?
overlay 是如何隔离的? 不同的 overlay 网络是相互隔离的. 创建第二个 overlay 网络 ov_net2 并运行容器 bbox3. docker network create -d ...
- Python学习笔记之参数解析
python提供了两种方法进行命令行的参数解析,分别是getopt和optparse类中的模块OptionParser,下面分别详细了解这两个模块: 1.getopt模块 首先复习C语言的命令行解析: ...
- C# 获取当前服务器运行程序的根目录
C# 获取当前服务器运行程序的根目录,获取当前运行程序物理路径 string tmpRootDir = AppDomain.CurrentDomain.BaseDirectory;//获得当前服务器程 ...
- Mycat安装教程
1.下载: https://github.com/MyCATApache/Mycat-download 具体下载哪个版本以发布为准,推荐1.4,1.5. 2.安装: 安全前,在Linu ...
- VueJs大全;vee-validate(一个验证vue插件), bootstrap-vue, axios简介。
Vue.js大全(包括依赖,插件,好的指导文章等!)
- java 循环读取文件夹里面的文件
public ArrayList<String> list = new ArrayList<String>(0);//用arraylist保存扫描到的路径public void ...
- 151. Reverse Words in a String(java 注意细节处理)
题目:reverse words in a string Given an input string, reverse the string word by word. For example,Giv ...