# uva 1030 - Image Is Everything(迭代更新）

#include <stdio.h>
#include <string.h>

#define REP(i,n) for (int i = 0; i < (n); i++)
const int N = 15;

int n;
char view[N][N][N], pos[N][N][N];

char getChar() {
char ch;
while (true) {
ch = getchar();
if ((ch >= 'A' && ch <= 'Z') || ch == '.') return ch;
}
}

void input() {
REP(i, n) REP(k, 6) REP(j, n) view[k][i][j] = getChar();
REP(x, n) REP(y, n) REP(z, n) pos[x][y][z] = '#';
}

void search(int i, int j, int k, int p, int& x, int& y, int& z) {
switch(k) {
case 0:
x = i, y = j, z = p; return;
case 1:
x = i, y = p, z = n - j - 1; return;
case 2:
x = i, y = n - j - 1, z = n - p - 1; return;
case 3:
x = i, y = n - p - 1, z = j; return;
case 4:
x = p, y = j, z = n - i - 1; return;
case 5:
x = n - p - 1, y = j, z = i; return;
}
}

int solve() {

int x, y, z;

REP(k, 6) REP(i, n) REP(j, n)
if (view[k][i][j] == '.')
REP(p, n) {
search(i, j, k, p, x, y, z);
pos[x][y][z] = '.';
}

while (true) {
bool flag = true;
REP(k, 6) REP(i, n) REP(j, n)
if (view[k][i][j] != '.')
REP(p, n) {
search(i, j, k, p, x, y, z);
if (pos[x][y][z] == '.') continue;
if (pos[x][y][z] == '#')
pos[x][y][z] = view[k][i][j];

if(pos[x][y][z] == view[k][i][j]) break;
pos[x][y][z] = '.';
flag = false;
}
if (flag) break;
}

int ans = 0;
REP(x, n) REP(y, n) REP(z, n)
if (pos[x][y][z] != '.') ans++;
return ans;
}

int main () {
while (scanf("%d", &n) == 1 && n) {
input();
printf("Maximum weight: %d gram(s)\n", solve() );
}
return 0;
}


• 本文已收录于以下专栏：

## uva1030 Image Is Everything

• sdfzyhx
• 2016年11月07日 20:11
• 66

## 例题1.6 立方体成像 UVa1030

1.题目描述：点击打开链接 2.解题思路：本题只给了六个视图，要求找最大的立方块数，看上去貌似很棘手的一个问题。我们可以尝试用排除法，如果删到不能删除时，那么剩下的立方块自然就是最多的。由于视图中为...

## World Finals 2004 / UVa 1030 Image Is Everything (想法题&迭代更新)

1030 - Image Is Everything Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com...

## uva 1030 Image Is Everything（迭代更新）

uva 1030 Image Is Everything Your new company is building a robot that can hold small lightwe...

## UVA 1030 - Image Is Everything(贪心枚举)

Description Your new company is building a robot that can hold small lightweight objects. The rob...

## UVaLive-2995 Image Is Everything

举报原因： 您举报文章：uva 1030 - Image Is Everything(迭代更新） 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)