【习题 4-4 UVA - 253】Cube painting
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
绕(x,y,z)三个轴旋转。
枚举x,y,z各4次的结果。
(4次之后能还原。可以方便上一层枚举下一个情况。)
【代码】
#include <bits/stdc++.h>
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
using namespace std;
const int N = 12;
char s[N+10];
char s1[N+5],s2[N+5];
int ope[3][4]={
{1,2,6,5},
{2,4,5,3},
{1,4,6,3}
};
void operation(int p){
char key = s2[ope[p][3]];
rep2(i,3,1) s2[ope[p][i]] = s2[ope[p][i-1]];
s2[ope[p][0]] = key;
}
bool judge(){
for (int i = 1;i <= 4;i++){
operation(0);
for (int j = 1;j <= 4;j++){
operation(1);
for (int k = 1;k <= 4;k++){
operation(2);
int ok = 1;
rep1(kk,1,6)
if (s1[kk]!=s2[kk]){
ok = 0;
break;
}
if (ok){
return true;
}
}
}
}
return false;
}
int main(){
//freopen("/home/ccy/rush.txt","r",stdin);
// freopen("/home/ccy/rush_out.txt","w",stdout);
ios::sync_with_stdio(0),cin.tie(0);
while (cin >> (s+1)){
rep1(i,1,6) s1[i] = s[i];
rep1(i,7,12) s2[i-6] = s[i];
if (judge()){
cout<<"TRUE"<<endl;
}else{
cout<<"FALSE"<<endl;
}
}
return 0;
}
【习题 4-4 UVA - 253】Cube painting的更多相关文章
- UVA 253 Cube painting(暴力打表)
Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...
- uva 253 - Cube painting(相同骰子)
习题4-4 骰子涂色(Cube painting, UVa 253) 输入两个骰子,判断二者是否等价.每个骰子用6个字母表示,如图4-7所示. 图4-7 骰子涂色 例如rbgggr和rggbgr分别表 ...
- UVA 253 Cube painting
大致题意:有三种颜色,一个立方体6面都可以涂一种颜色.现在给出两个每个面都涂好颜色的立方体,判断这两个立方体通过旋转是否相等. 立方体的旋转出来的结果有很多,首先可以0,1,2,3,4,5(顺序是:上 ...
- UVA 253 Cube painting(枚举 模拟)
题意: 按如图的顺序给定2个骰子的颜色(只有r.b.g三种颜色) 问2个骰子是否一模一样 如 可表示为“rbgggr” 和 “rggbgr”, 第二个就是绕着Z轴顺时针旋转90度与第一个相同的骰子. ...
- UVa 253 Cube paiting
题意:输入两个骰子,判断是否等价 因为每一个面可以作顶面,共6*4种情况,枚举就可以了 #include<iostream> #include<cstdio> #include ...
- UVA 253 (13.08.06)
Cube painting We have a machine for painting cubes. It is supplied withthree different colors: blu ...
- UVa 253
UVa 253 #include <iostream> #include <cstdio> #include <string> #include <cstri ...
- Cube painting UVA - 253
We have a machine for painting cubes. It is supplied with three different colors: blue, red and gre ...
- 骰子涂色 (Cube painting,UVa 253)
题目描述:算法竞赛入门习题4-4 题目思路:1.旋转其中一个骰子进行匹配 2.进行遍历,如果匹配,就进行相对面的匹配 3.三个对立面都匹配即是一样等价的 //没有按照原题的输入输出 #include ...
随机推荐
- JSP 获取Request 经常使用參数
<input type="hidden" id="a" value="<%=request.getScheme()%>" ...
- 请求文件下载URL过长处理
/* * PostNewWin * Author:ppchen */var PostNewWin = function(url){ var urlArr = url.split("?& ...
- 树形 DP 总结
树形 DP 总结 本文转自:http://blog.csdn.net/angon823/article/details/52334548 介绍 1.什么是树型动态规划 顾名思义,树型动态规划就是在“树 ...
- KD树——k=1时就是BST,里面的数学原理还是有不明白的地方,为啥方差划分?
Kd-Tree,即K-dimensional tree,是一棵二叉树,树中存储的是一些K维数据.在一个K维数据集合上构建一棵Kd-Tree代表了对该K维数据集合构成的K维空间的一个划分,即树中的每个结 ...
- C# SuperSocket服务端入门(一)
1,新建一个控制台应用程序,.NET版本4.0 2,添加SuperSocket(1.6.1).Binaries\Net40\Debug 目录下的: SuperSocket的dll文件( log4ne ...
- constraint和index--转载
primary key和unique约束是要依赖index的,下面通过试验来看看他们之间的依赖关系! SQL> select * from tt; ID NA --------- ...
- 认识JS的基础对象,定义对象的方法
JS的基础对象: 1.window //窗口对象 2.document //文档对象 3.document.documentElement //html对象 4.docume ...
- jsp页面导入excel文件的步骤及配置
上传使用flash插件 需要jquery.uploadify.min.js,uploadify.css,poi-ooxml-3.8-20120326.jar等 jsp页面: <%@include ...
- EasyUI 编写实体类树状选择器
<%@ page contentType="text/html;charset=UTF-8"%> <%@ include file="/WEB-INF/ ...
- SQLServer2008 在where条件中使用CASE WHEN
create table #temp( id int identity(1,1), name varchar(20), startYear int, startMonth in ...