UVa 253: Cube painting
来源:互联网 发布:北京宏观经济数据 编辑:程序博客网 时间:2024/04/26 05:50
这道题要我们判断对于一个立方体用三种颜色染色(可以只使用其中的一种或两种颜色),题目所给的两种染色方案本质上是否相同(即立方体经过翻转后可重合)。
对于这道题,我们只要枚举出第一种染色方案下的立方体所有能够通过翻转产生的其他本质相同的染色方案,与第二种方案比较就可以得到结果。
即枚举立方体绕X,Y,Z轴旋转后的结果(三个轴均可以绕着旋转0度,90度,180度,270度),最多4^3=64中情况。
我的解题代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <string>#include <algorithm>using namespace std;const int X_rotate[4][6]= { 1, 2, 3, 4, 5, 6,3, 2, 6, 1, 5, 4,6, 2, 4, 3, 5, 1,4, 2, 1, 6, 5, 3};const int Y_rotate[4][6]= { 1, 2, 3, 4, 5, 6,5, 1, 3, 4, 6, 2,6, 5, 3, 4, 2, 1,2, 6, 3, 4, 1, 5};const int Z_rotate[4][6]= { 1, 2, 3, 4, 5, 6,1, 4, 2, 5, 3, 6,1, 5, 4, 3, 2, 6,1, 3, 5, 2, 4, 6};char s[16],s1[8],s2[8],s3[8];int main(){while(cin >> s){int ok=0;for(int i=0; i<4; i++) if(!ok){for(int t=0; t<6; t++) s1[t]=s[X_rotate[i][t]-1];for(int j=0; j<4; j++) if(!ok){for(int t=0; t<6; t++) s2[t]=s1[Y_rotate[j][t]-1];for(int k=0; k<4; k++) if(!ok){for(int t=0; t<6; t++) s3[t]=s2[Z_rotate[k][t]-1];int ok2=1;for(int t=0; t<6; t++) if(s3[t]!=s[t+6]){ ok2=0; break;}if(ok2) ok=1;}}}if(ok) cout << "TRUE\n";else cout << "FALSE\n";}return 0;}
- UVa 253 - Cube painting
- Uva 253 - Cube painting
- Uva 253 Cube Painting
- uva 253 Cube painting
- uva 253 - Cube painting
- UVa 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 - Cube painting
- UVA 253 Cube painting
- UVa 253: Cube painting
- uva 253 - Cube painting
- uva 253 Cube painting
- UVA 253 Cube painting
- 253 - Cube painting UVA
- UVa 253 Cube painting
- UVA-253-Cube painting
- UVa 253 - Cube painting
- UVA 253 Cube painting
- 《Robust java》学习-第三章高级异常处理概念
- 【Cocos2d-X开发学习笔记】第10期:渲染框架之几何图形的绘制
- 水题一发——重在细节
- [Android]菜单简介和实现
- openGL函数二
- UVa 253: Cube painting
- 【组件】plupload及相应服务器文件管理实现
- hdu 2039 三角形
- 数据结构之图-邻接矩阵
- Ruby学习笔记(一)
- openGL函数一
- Linux学习(1)vi编辑器的常用命令
- ckfinder.net完全讲解三(添加页面显示餐单)
- DataTable的XML序列化与反序列化