题目

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. GridView实现拖拽排序以及数据交互

    在研究项目中的一个效果的时候,查找资料过程中发现有人有这么一种需求,就是GridView在实现拖拽排序的基础上,如果是两个GridView之间实现拖拽效果,并要实现数据交互. 一.效果图: 实现这个效 ...

  2. anusplina 4.36版本使用提示 说明

    1),必须要注意的是,你生成的dat文件中,第一列必须是气象站点编号:第二列必须是经度数值,而且是投影坐标下,以 米 为单位:第三列必须是纬度了:第四列必须是海拔了:之后就是你自己的数据,比如平均温度 ...

  3. 关于js函数,方法,对象实例的一些说明

    朋友们大家好,好久没有更新文章了,最近正好有空就想着写点什么吧,加上这段时间总是能听到一些朋友们问关于js函数,方法,对象实例到底有什么区别这个问题,所以今天就献丑来简单说明一些吧! 其实这些主要都是 ...

  4. 2018年浙江理工大学程序设计竞赛校赛 Problem I: 沙僧

    沙僧 思路: dfs序+差分数组 分层考虑,通过dfs序来查找修改的区间段,然后用差分数组修改 代码: #include<bits/stdc++.h> using namespace st ...

  5. css的table布局

    1.table中对tr设置margin-top是没有作用的.

  6. (转)c# String与StringBuilder

    阅读目录 1.什么时候用String?什么时候用StringBuilder? 2.String与StringBuilder的区别 总结   1.什么时候用String?什么时候用StringBuild ...

  7. JavaScript 第三章总结

    Getting functional function的特点 function can be reused over and over much more readable function is p ...

  8. Java 反射(简单捋一下)

    有Student类,Person类,还有一个叫Class的类,这是反射的源头. 正常方式:通过完整的类名 > 通过new实例化 > 取得实例化对象 反射方式:实例化对象 > getC ...

  9. No address associated with hostname

    java.net.UnknownHostException: Unable to resolve host "www.baidu.com": No address associat ...

  10. JS实现继承的6种方式

    使用pretotype,call实现完美继承 父类: fuction Animal(name){     this.name=name||"Animal";     this.sl ...