题意:

按如图的顺序给定2个骰子的颜色(只有r、b、g三种颜色)

问2个骰子是否一模一样

可表示为“rbgggr” 和 “rggbgr”, 第二个就是绕着Z轴顺时针旋转90度与第一个相同的骰子.

分析:

记录一个错误的做法:并不是只要两面两面互相映射, 如rbrggb 与 rgrgbb, 即使 rb 对应 rb、gb 对应 bg、 rg对应rg, 但他们并不是一模一样的骰子。(可以借助真正的骰子旋转尝试一下,就是123456 和 153426, 想象一下2与5互换, 根本不可能从原来的骰子转出来)

正确做法是枚举每一个面向上, 然后分别绕Z轴旋转90度, 每个面有4种情况, 总共24种情况, 再与原来的对应匹配就好, 24个不算太多我就把表打出来了, 其实可以仔细找一下规律, 减少代码量。

代码:

 #include <bits/stdc++.h>
using namespace std;
int dir[][] = {{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},
{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},
{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,},{,,,,,}};
char t[];
bool judge(int kase)
{
for(int i = ; i < ; i++){
if(t[i] != t[dir[kase][i] + ])
return false;
}
return true;
}
int main()
{ while(scanf("%s", &t) != EOF){
int ok = ;
for(int i = ; i < ; i++){
if(judge(i)) ok = ;
}
printf("%s\n", ok? "TRUE":"FALSE");
}
return ;
}

UVA 253 Cube painting(枚举 模拟)的更多相关文章

  1. UVA 253 Cube painting(暴力打表)

    Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...

  2. uva 253 - Cube painting(相同骰子)

    习题4-4 骰子涂色(Cube painting, UVa 253) 输入两个骰子,判断二者是否等价.每个骰子用6个字母表示,如图4-7所示. 图4-7 骰子涂色 例如rbgggr和rggbgr分别表 ...

  3. UVA 253 Cube painting

    大致题意:有三种颜色,一个立方体6面都可以涂一种颜色.现在给出两个每个面都涂好颜色的立方体,判断这两个立方体通过旋转是否相等. 立方体的旋转出来的结果有很多,首先可以0,1,2,3,4,5(顺序是:上 ...

  4. UVa 253 Cube paiting

    题意:输入两个骰子,判断是否等价 因为每一个面可以作顶面,共6*4种情况,枚举就可以了 #include<iostream> #include<cstdio> #include ...

  5. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  6. UVa 253

    UVa 253 #include <iostream> #include <cstdio> #include <string> #include <cstri ...

  7. Cube painting UVA - 253

     We have a machine for painting cubes. It is supplied with three different colors: blue, red and gre ...

  8. 【习题 4-4 UVA - 253】Cube painting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 绕(x,y,z)三个轴旋转. 枚举x,y,z各4次的结果. (4次之后能还原.可以方便上一层枚举下一个情况.) [代码] #incl ...

  9. 骰子涂色 (Cube painting,UVa 253)

    题目描述:算法竞赛入门习题4-4  题目思路:1.旋转其中一个骰子进行匹配 2.进行遍历,如果匹配,就进行相对面的匹配 3.三个对立面都匹配即是一样等价的 //没有按照原题的输入输出 #include ...

随机推荐

  1. Six degrees of Kevin Bacon

    转自:https://blog.csdn.net/a17865569022/article/details/78766867 Input* Line 1: Two space-separated in ...

  2. jQuery查找

    导航查找方法: 向下查找兄弟标签: $().next() $().nextAll() 向上查找兄弟标签: 可以查找所有兄弟标签: 查找子标签 查找父级标签: $().parent() $().pare ...

  3. How many Fibs? POJ - 2413

    How many Fibs? POJ - 2413 高精模板 #include<cstdio> #include<cstring> #include<algorithm& ...

  4. Oracle10g安装过程中ORA-27125问题解决

    Oracle10g在CentOS7的安装过程中报错如下错误信息: ORA-: unable to create shared memory segment 解决办法: [root@dbsrv3 dat ...

  5. js中实现json格式的转换

    function person(id,name,age){ this.id=id; this.name=name; this.age=age; } var p=new person(1001,'tom ...

  6. Solr中的group与facet的区别 [转]

    Solr中的group与facet的区别 facet 自己理解就是分组聚合用的, 如下说明 http://blog.csdn.net/a925907195/article/details/472572 ...

  7. R Programming week1-Subsetting

    Subsetting There are a number of operators that can be used to extract subsets of R objects. [ alway ...

  8. vultr服务器L2TP搭建

    前期准备,购买外服,选择vultr服务商,可选择洛杉矶的,系统为Ubuntu 14.04 x64 一.安装L2TP/IPSec wget --no-check-certificate https:// ...

  9. .Net Core 真能令微软的.Net 跨平台“蔓延”?

    什么是.Net .Net 本身就是基于公共语言基础架构(CLI)实现的平台独立的公共语言开发平台,只是自2006年成为规范以来的CLI,只有Windows自己支持罢了(mono除外).微软的.Net ...

  10. (转)淘淘商城系列——SSM框架整合之Dao层整合

    http://blog.csdn.net/yerenyuan_pku/article/details/72721093 一个项目中往往有三层即Dao层.Service层和Web层,看标题就知道了,本文 ...