题目

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. Codeforces 1005 F - Berland and the Shortest Paths

    F - Berland and the Shortest Paths 思路: bfs+dfs 首先,bfs找出1到其他点的最短路径大小dis[i] 然后对于2...n中的每个节点u,找到它所能改变的所 ...

  2. sql server 学习笔记 ( backup 备份方案 )

    做个记入就好 USE [master] SELECT bs.database_name AS 'Database Name', bs.backup_start_date AS 'Backup Star ...

  3. json包

    1.官网下载 2.pom文件下载: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId&g ...

  4. ubuntu 16.04 下安装smplayer视频播放器

    安装平台:ubuntu 16.04 1.sudo apt-add-repository ppa:rvm/smplayer 2.sudo apt-get update 3.sudo apt-get in ...

  5. Learn Python3 the hard way 第一天总结 命令行(1)

    附录-命令行快速入门(1) command line interface 简称 CLI ,可以在mac OS 上通过一些输入进行一些操作. 1如何在迷路后怎样回家 命令: pwd:打印工作目录cd 更 ...

  6. HDOJ 1022 Train Problem

    两个数组存进出顺序,如果不同进栈,相同出栈.

  7. 内核开启VF小结

    2017-8-29 16:33:40 内核开启VF小结: 1. eth2上创建4个VFecho 4 > /sys/class/net/eth2/device/sriov_numvfs2. 关闭e ...

  8. Fox And Dinner CodeForces - 510E (最大流)

    大意: n只狐狸, 要求分成若干个环, 每个环的狐狸不少于三只, 相邻狐狸年龄和为素数. 狐狸年龄都>=2, 那么素数一定为奇数, 相邻必须是一奇一偶, 也就是一个二分图, 源点向奇数点连容量为 ...

  9. Remove Duplicates From Sorted Array leetcode java

    算法描述: Given a sorted array, remove the duplicates in place such that each element appear only once a ...

  10. Python安装第三方库,报错超时: Read timed out.

    1.安装beautifulsoup4 >pip install beautifulsoup4 报错超时: Read timed out. 2.解决办法:pip --default-timeout ...