Dice

http://acm.hdu.edu.cn/showproblem.php?pid=5012

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2352    Accepted Submission(s): 1178

Problem Description
There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A. Similarly, consider b1.b2,b3,b4,b5,b6 to be numbers on specific faces of dice B. It’s guaranteed that all numbers written on dices are integers no smaller than 1 and no more than 6 while ai ≠ aj and bi ≠ bj for all i ≠ j. Specially, sum of numbers on opposite faces may not be 7.

At the beginning, the two dices may face different(which means there exist some i, ai ≠ bi). Ddy wants to make the two dices look the same from all directions(which means for all i, ai = bi) only by the following four rotation operations.(Please read the picture for more information)


Now Ddy wants to calculate the minimal steps that he has to take to achieve his goal.

 
Input
There are multiple test cases. Please process till EOF.

For each case, the first line consists of six integers a1,a2,a3,a4,a5,a6, representing the numbers on dice A.

The second line consists of six integers b1,b2,b3,b4,b5,b6, representing the numbers on dice B.

 
Output
For each test case, print a line with a number representing the answer. If there’s no way to make two dices exactly the same, output -1.
 
Sample Input
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 5 6 4 3
1 2 3 4 5 6
1 4 2 5 3 6
 
Sample Output
0
3
-1
 
Source
 
模拟搜索水题
 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdio>
#include<queue>
#include<map>
#include<vector>
typedef long long ll;
#define maxn 100005
using namespace std; int a[],b[];
map<int,int>mp;
struct sair{
int num,step;
}; sair Roll(sair tmp,int x){
//左右前后
sair ans;
ans.num=;
int aa[];
int xx=tmp.num;
for(int i=;i>=;i--){
a[i]=xx%;
xx/=;
}
if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else if(x==){
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
else{
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
ans.num=ans.num*+a[];
}
ans.step=tmp.step+;
return ans;
} void bfs(int S,int E){
sair s,e;
if(S==E){
cout<<<<endl;
return;
}
s.num=S,s.step=;
queue<sair>Q;
Q.push(s);
while(!Q.empty()){
s=Q.front();
Q.pop();
for(int i=;i<;i++){
e=Roll(s,i);
if(e.num==E){
cout<<e.step<<endl;
return;
}
if(!mp[e.num]){
Q.push(e);
mp[e.num]=;
}
}
}
cout<<-<<endl;
} int main(){
while(cin>>a[]){
mp.clear();
for(int i=;i<=;i++) cin>>a[i];
int S=,E=;
for(int i=;i<=;i++) E=E*+a[i];
for(int i=;i<=;i++) cin>>b[i];
for(int i=;i<=;i++) S=S*+b[i];
bfs(S,E);
}
}

Dice的更多相关文章

  1. HDOJ 4652 Dice

      期望DP +数学推导 Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. 三种renderman规范引擎的dice对比

    次表面做的有些烦躁,既然如此,索性先记一下前一阵比较的PIXIE.3delight.prman的dice方式. 研究过reyes的人都知道dice,简而言之,就是为了生成高质量高精度的图片(电影CG) ...

  3. LightOJ 1248 Dice (III) 概率

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  4. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  5. 概率 Gym 100502D Dice Game

    题目传送门 /* 题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布 问两人投掷,胜利的概率谁大 数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利 还有更简单的做 ...

  6. HDU 5955 Guessing the Dice Roll

    HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...

  7. UVALive 7275 Dice Cup (水题)

    Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...

  8. HDU 4586 A - Play the Dice 找规律

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. CF Polycarpus' Dice (数学)

    Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  10. [LOJ 1248] Dice (III)

    G - Dice (III) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Descri ...

随机推荐

  1. HTML5: SVG (可缩放矢量图形)

    ylbtech-HTML5: SVG (可缩放矢量图形) 可缩放矢量图形是基于可扩展标记语言(标准通用标记语言的子集),用于描述二维矢量图形的一种图形格式.它由万维网联盟制定,是一个开放标准. 1. ...

  2. 正则的使用及replace细讲

    1.var reg=/./ 与 var reg=/\./的区别? .代表任意一个字符 \.而后者代表这个字符串中得有一个. 2.?的使用 如果单独的一个字符后面带? /\d?/ 代表1个或0个这个字符 ...

  3. seaborn可视化特征的相关性

    import seaborn as sn sn.heatmap(trainX.corr(),vmax=1,square=True)

  4. 新手搭建 nginx + php (LNMP)

    配置源 纯净的Centos 6.5系统 配置163yum源 (这个比较简单,百度能解决很多问题) 开始 安装  开发软件包:yum  -y groupinstall  "Developmen ...

  5. 使用V$SQL_PLAN视图获取曾经执行过的SQL语句执行计划

    通常我们查看SQL语句的执行计划都是通过EXPLAIN PLAN或者AUTOTRACE来完成.但是这些查看方法有一个限制,它们都是人为触发而产生的,无法获得数据库系统中曾经执行过的SQL语句执行计划. ...

  6. TensorFlow相关的一些技巧

    谷歌开发技术推广工程师 Laurence Moroney 在 Google Cloud Next 大会上进行了一段 42 分钟的演讲,主题是「What's New with TensorFlow?」. ...

  7. Java反射机制 —— 简单了解

    一.概述 JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为jav ...

  8. nginx、TP框架实现兼容pathinfo和rewrite两种url访问方式

    环境:centos7,yum安装的nginx1.10.php-fpm,tp3.2 本方法只需要配置nginx.conf的一个文件就可以支持pathinfo和rewrite两种url访问方式 vim / ...

  9. sqoop2的使用测试

    查看现有link sqoop:000> show link+-----------+------------------------+---------+|   Name    |     Co ...

  10. 多数据源springboot-jta-atomikos

    参考:  https://github.com/classloader/springboot-jta-atomikos-demo 參考:二 :建议参考  https://blog.csdn.net/a ...