【习题 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 ...
随机推荐
- 封装RecyclerViewAdapter实现RecyclerView下拉刷新上拉载入很多其它
实现 关于下拉刷新使用的是github上的项目Ultra Pull To Refresh项目. gradle依赖例如以下: compile 'in.srain.cube:ultra-ptr:1.0.1 ...
- 菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上)
菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上) Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog. ...
- 使用U-Boot的TFTP(远程/网络内核)
前提条件 假设您的主机PC运行的是Ubuntu 14.04.1 LTS或更高版本,并且与您的开发平台在同一个本地网络上;为了简单起见,我们假设网络上也有DHCP服务器.如果使用Juno,请确保使用的是 ...
- 更改printk打印级别【转】
本文转载自:http://blog.csdn.net/weed_hz/article/details/8949140 1.查看当前控制台的打印级别 cat /proc/sys/kernel/print ...
- hdoj- Windows Message Queue
Windows Message Queue Problem Description Message queue is the basic fundamental of windows system. ...
- 第14课 SourceTree程序操作介绍
http://www.atlassian.com/software/sourcetree/overview https://www.microsoft.com/net/framework/versio ...
- 3个不常用的HTML标签
html标签众多,在HTML手册里你可以都查到.但有的HTML标签你可能从未使用过.不是因为你欠缺学习精神,而是它们确实用处不大.如果你有探索精神,那就接着往下看吧. 第一个:<abbr> ...
- POJ 1330 Tarjan LCA、ST表(其实可以数组模拟)
题意:给你一棵树,求两个点的最近公共祖先. 思路:因为只有一组询问,直接数组模拟好了. (写得比较乱) 原题请戳这里 #include <cstdio> #include <bits ...
- CDH版Phoenix的安装(图文详解)
不多说,直接上干货! 写在前面的话 我这里,四个节点的bigdata集群.分别为cmbigdata1.cmbigdata2.cmbigdata3和cmbigdata4. https://i.cnblo ...
- (转)vuex2.0 基本使用(2) --- mutation 和 action
我们的项目非常简单,当点击+1按钮的时候,count 加1,点击-1按钮的时候,count 减1. 1, mutation The only way to actually change state ...