Image Is Everything UVALive
来源:互联网 发布:dvd自动播放软件 编辑:程序博客网 时间:2024/06/06 10:03
建立一个体积为n*n*n的正方体,由六视图,删除空的小方块,然后遍历正方体,空出的地方,是否存在矛盾,并删除矛盾的方块
#include<cstring>#include<cmath>#include<algorithm>#include<iostream>#include<cstdio>using namespace std;#define REP(i, n) for(int i = 0; i < (n); ++i)const int MAXN = 10;int n;char pos[MAXN][MAXN][MAXN];char view[6][MAXN][MAXN];char read_char() { //读颜色函数 char ch; for(;;) { ch = getchar(); if((ch >= 'A' && ch <= 'Z') || ch == '.') { return ch; } }}void get(int k, int i, int j, int len, int &x, int &y, int &z) { switch (k) { case 0: { x = len; y = j; z = i; break; } case 1: { x = n - 1 - j; y = len; z = i; break; } case 2: { x = n - 1 - len; y = n - 1 - j; z = i; break; } case 3: { x = j; y = n - 1 - len; z = i; break; } case 4: { x = n - 1 - i; y = j; z = len; break; } case 5: { x = i; y = j; z = n - 1 - len; break; } }}int main() { while(scanf("%d", &n) == 1 && n) { //读入视图 REP(i, n)//行数 REP(k, 6)//6面 REP(j, n) view[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(view[k][i][j] == '.') { //此位置为空。可透视,无方块 REP(p, n) { int x, y, z; //穿透经过的点的坐标 get(k, i, j, p, x, y, z); //平面视图变换到具体位置 pos[x][y][z] = '.'; //将该点置空 }//穿透 } // int cnt = 0; for(;;) { bool done = true; REP(k, 6) REP(i, n) REP(j, n) { //cnt++; if(view[k][i][j] != '.') { //cout << 666 << endl; REP(p, n) { int x, y, z; get(k, i, j, p, x, y, z); //平面视图变换到具体位置 if(pos[x][y][z] == '.') { //不作处理 continue; } if(pos[x][y][z] == '#') { //染色 pos[x][y][z] = view[k][i][j]; break; } if(pos[x][y][z] == view[k][i][j]) {//颜色相同 break; } pos[x][y][z] = '.';//颜色不同,删除该点 done = false; } } } if(done) { break; } } // cout << cnt << endl; int ans = 0;//计算答案 REP(i, n) REP(j, n) REP(k, n) if(pos[i][j][k] != '.') { ans++; } printf("Maximum weight: %d gram(s)\n", ans); } return 0;}
阅读全文
0 0
- Image Is Everything UVALive
- UVALive 2995 Image Is Everything
- UVaLive-2995 Image Is Everything
- UVALive 2995 Image Is Everything 策略问题
- UVaLive 2995 Image Is Everything 立方体成像
- UVaLive 2995 Image Is Everything (贪心+模拟)
- UVALive 2995Image Is Everything 策略问题
- UVALive.2995 Image Is Everything (思维题 三维坐标转换)
- Image Is Everything
- Image Is Everything
- LA2995- Image Is Everything
- uva1030 Image Is Everything
- 1030 - Image Is Everything
- Uva-1030-Image Is Everything
- Image Is Everything(立方体成像)
- la 2995 Image is everything
- 1030 - Image Is Everything (贪心)
- Uva 1030 - Image Is Everything
- Java FileReader 读取方式2
- poj 1637 Sightseeing tour 混合图的欧拉回路
- 构造方法
- 求水仙花数
- Python 矩阵
- Image Is Everything UVALive
- 面向对象总结篇
- 关于oracle重复数据合并以及.前面加0问题的解决
- 电阻抗断层成像开源软件eidors3.8的入门使用方法
- NOIP模拟9.28
- 表示数值的字符串
- Struts2 流程详解
- C++异常处理
- 数组