Image Is Everything UVALive - 2995 World Finals 2004

Your new company is building a robot that can hold small lightweight objects. The robot will have
the intelligence to determine if an object is light enough to hold. It does this by taking pictures of the
object from the 6 cardinal directions, and then inferring an upper limit on the object’s weight based
on those images. You must write a program to do that for the robot.
You can assume that each object is formed from an
N

N

N
lattice of cubes, some of which
may be missing. Each 1

1

1 cube weighs 1 gram, and each cube is painted a single solid color. The
object is not necessarily connected.
Input
The input for this problem consists of several test cases representing different objects. Every case
begins with a line containing
N
, which is the size of the object (1

N

10). The next
N
lines are
the different
N

N
views of the object, in the order front, left, back, right, top, bottom. Each view
will be separated by a single space from the view that follows it. The bottom edge of the top view
corresponds to the top edge of the front view. Similarly, the top edge of the bottom view corresponds
to the bottom edge of the front view. In each view, colors are represented by single, unique capital
letters, while a period (
.
) indicates that the object can be seen through at that location.
Input for the last test case is followed by a line consisting of the number `
0
'.
Output
For each test case, print a line containing the maximum possible weight of the object, using the format
shown below.
Sample Input
3
.R. YYR .Y. RYY .Y. .R.
GRB YGR BYG RBY GYB GRB
.R. YRR .Y. RRY .R. .Y.
2
ZZ ZZ ZZ ZZ ZZ ZZ
ZZ ZZ ZZ ZZ ZZ ZZ
0
Sample Output
Maximum weight: 11 gram(s)
Maximum weight: 8 gram(s)


给定一个 N * N * N 的立方体,部分块缺失,现给出6个面所观察到的状态,求问最多有多少个小立方体(总体积);

getpos 表示 在第k个面中,第 i 行 j 列,深度为 len 时,该木块所在的 (x,y,z)坐标;
参考 lrj 的代码实现;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize("O3")
using namespace std;
#define maxn 300005
#define inf 0x3f3f3f3f
#define INF 2147480000
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const int mod = 10000007;
#define Mod 20100403
#define sq(x) (x)*(x)
#define eps 1e-7
typedef pair<int, int> pii;
#define pi acos(-1.0)
const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)

inline int rd() {
	int x = 0;
	char c = getchar();
	bool f = false;
	while (!isdigit(c)) {
		if (c == '-') f = true;
		c = getchar();
	}
	while (isdigit(c)) {
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	return f ? -x : x;
}

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; }

int n;
char pos[20][20][20];
char vw[6][20][20];

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

void getPos(int k, int i, int j, int len, int &x, int &y, int &z) {
	if (k == 0)x = len, y = j, z = i;
	if (k == 1)x = n - 1 - j, y = len, z = i;
	if (k == 2)x = n - 1 - len, z = i, y = n - 1 - j;
	if (k == 3)x = j, y = n - 1 - len, z = i;
	if (k == 4)x = n - 1 - i, y = j, z = len;
	if (k == 5)x = i, y = j, z = n - 1 - len;
}

int main()
{
	//ios::sync_with_stdio(false);
	while (cin >> n && n) {
		REP(i, n) REP(k, 6) REP(j, n)vw[k][i][j] = read_char();
		REP(i, n) REP(j, n) REP(k, n) pos[i][j][k] = '#';
		
		REP(k, 6) REP(i, n) REP(j, n) if (vw[k][i][j] == '.') {
			REP(len, n) {
				int x, y, z; getPos(k, i, j, len, x, y, z);
				pos[x][y][z] = '.';
			}
		}
		while (1) {
			bool fg = true;
			REP(k, 6) REP(i, n) REP(j, n) if (vw[k][i][j] != '.') {
				REP(p, n) {
					int x, y, z; getPos(k, i, j, p, x, y, z);
					if (pos[x][y][z] == '.')continue;
					if (pos[x][y][z] == '#') {
						pos[x][y][z] = vw[k][i][j]; break;
					}
					if (pos[x][y][z] == vw[k][i][j])break;
				//	pos[x][y][z] = '.'; 
					fg = false;
				}
			}
			if (fg)break;
		}
		int tot = 0;
		REP(i, n)
			REP(j, n) REP(k, n) if (pos[i][j][k] != '.')tot++;
		printf("Maximum weight: %d gram(s)\n", tot);
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 你可以在 CSDN 上创建一个项目,然后将文件上传到该项目中。具体步骤是:登录 CSDN,进入个人中心,点击“我的项目”,然后点击“创建项目”,填写项目信息,选择“上传文件”,将文件上传到项目中即可。如果你遇到了问题,可以在 CSDN 的帮助中心中查找相关的教程或者向客服咨询。 ### 回答2: 要上传文件到“finals hell”,您可以按照以下步骤操作: 1. 首先,打开您的电脑,并连接到互联网。 2. 打开您的网页浏览器,并键入“finalshell.com”。然后按下“Enter”键,访问“finals hell”网站。 3. 如果您还没有账户,请先注册一个新的账户。您需要提供有效的电子邮件地址和创建一个安全的密码。完成填写后,按照账户创建的指引完成注册。 4. 注册完成后,使用您的电子邮件地址和密码登录到“finals hell”账户。 5. 在登录后的页面上,您将找到一个“上传文件”或类似的选项。通常,它会显示为一个按钮或一个图标。 6. 单击“上传文件”选项,这将打开一个文件浏览器对话框。 7. 在文件浏览器对话框中,浏览并选择您要上传的文件。您可以通过双击文件或者选择文件后点击“打开”按钮来选取文件。 8. 一旦您选择了文件,等待上传完成。此过程的时间取决于文件大小和您的互联网连接速度。 9. 上传完成后,您将收到通知或者文件会在页面上显示。您现在可以将该文件与其他人共享或者进行其他相关操作。 10. 完成后,您可以继续上传其他文件或者退出“finals hell”账户。 请注意,以上步骤仅为基本指导。根据具体情况,界面和操作可能会略有不同。对于更详细的指导,请参考“finals hell”网站上的帮助文档或联系他们的客户支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值