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. Lua中的metatable详解

    转自:http://www.jb51.net/article/56690.htm Lua 中 metatable 是一个普通的 table,但其主要有以下几个功能: 1.定义算术操作符和关系操作符的行 ...

  2. PHP学习方法总结

    怎样快速学好PHP技术  PHP学习方法总结   怎样快速学好PHP技术?我想这应该是大多数参加PHP培训学习PHP的同学比较关心和想要知道的问题,今天扣丁学堂小编就给大家简单谈谈怎样快速学好PHP技 ...

  3. php表达式

    表达式是PHP中一个重要的概念,可以把表达式理解为“任何有值的东西”.在本教程中涉及到表达式的语法,我们以“expr”来表示表达式. 下面就是一个表达式: $x > $y; 在上面的例子中,当$ ...

  4. blktrace未公开选项网络保存截取数据

    本文链接地址: blktrace未公开选项网络保存截取数据 我们透过blktrace来观察io行为的时候,第一件事情需要选择目标设备,以便分析该设备的io行为.具体使用可以参考我之前写的几篇:这里 这 ...

  5. 基于Redis位图实现用户签到功能

    场景需求 适用场景如签到送积分.签到领取奖励等,大致需求如下: 签到1天送1积分,连续签到2天送2积分,3天送3积分,3天以上均送3积分等. 如果连续签到中断,则重置计数,每月初重置计数. 当月签到满 ...

  6. 异步与websocket

    异步与WebSockets 知识点 理解同步与异步执行过程 理解异步代码的回调写法与yield写法 Tornado异步 异步Web客户端AsyncHTTPClient tornado.web.asyn ...

  7. CUDA C Programming Guide 在线教程学习笔记 Part 8

    ▶ 线程束表决函数(Warp Vote Functions) ● 用于同一线程束内各线程通信和计算规约指标. // device_functions.h,cc < 9.0 __DEVICE_FU ...

  8. controller检查header

    以前都只能拿到request再检查,其实有相应的注解. public Result updateRecentScore(@RequestBody Map map, @RequestHeader(&qu ...

  9. C# IIS 服务器 HTTP 错误 500.21 - Internal Server Error 解决办法

    <1> 管理员身份启动控制台 <2> 输入 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe ...

  10. VBA 浏览文件夹

    Private Function SelectFolder() As String        With Application.FileDialog(msoFileDialogFolderPick ...