# 100642D GYM

Problem C: Hexagon Perplexagon
A well known puzzle consists of 7 hexagonal pieces, each with the numbers 1 through 6 printed on the
sides. Each piece has a di erent arrangement of the numbers on its sides, and the object is to place the
7 pieces in the arrangement shown below such that the numbers on each shared edge of the arrangement
are identical. Figure (a) is an example of one solution:
(a) Example Solution
(b) Position Notation for Output
Rotating any solution also gives another trivially identical solution. To avoid this redundancy, we will
only deal with solutions which have a 1 on the uppermost edge of the central piece, as in the example.
Input
The rst line of the input le will contain a single integer indicating the number of test cases. Each case
will consist of a single line containing 42 integers. The rst 6 represent the values on piece 0 listed in
clockwise order; the second 6 represent the values on piece 1, and so on.
Output
For each test case, output the case number (using the format shown below) followed by either the phrase
No solution
or by a solution speci cation. A solution speci cation lists the piece numbers in the order
shown in the Position Notation of Figure (b). Thus if piece 3 is in the center, a 3 is printed rst; if
piece 0 is at the top, 0 is printed second, and so on. Each test case is guaranteed to have at most one
solution.
Sample Input
2
3 5 6 1 2 4 5 1 2 3 6 4 2 3 5 4 1 6 3 1 5 6 2 4 5 4 1 3 6 2 4 2 3 1 5 6 3 6 1 2 4 5
6 3 4 1 2 5 6 4 3 2 5 1 6 5 3 2 4 1 5 4 6 3 2 1 2 5 6 1 4 3 4 6 3 5 2 1 1 3 5 2 6 4
Sample Output
Case 1: 3 0 5 6 1 4 2
Case 2: No solution

#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <string>
#include <vector>
#include <math.h>
#include <time.h>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
const int dx[]={0,3,4,5,6,1,2},dy[]={0,5,6,1,2,3,4};
const int pos[]={0,4,5,6,1,2,3};
int n,stamp,T;
int used[8],b[8];
struct round{//还可以这么用
int a[10];
void scan()
{
for(int i=1;i<=6;i++)
cin>>a[i];
}
void rot()
{
int temp=a[1];
for(int i=1;i<6;i++)
a[i]=a[i+1];
a[6]=temp;
}
}a[8],t[8];
bool dfs(int d)
{
if(d==7)
{
for(int i=0;i<7;i++)
cout<<b[i]<<" ";
cout<<endl;
return true;
}
for(int i=0;i<7;i++)
{
if(used[i])continue;
t[d]=a[i];
b[d]=i;
if(d==0)
while(t[0].a[1]!=1)t[0].rot();
else
{
while(t[d].a[pos[d]]!=t[0].a[d])t[d].rot();
if(d==6&&t[d].a[dx[d]]!=t[1].a[dy[1]])continue;
if(d>1&&t[d].a[dy[d]]!=t[d-1].a[dx[d-1]])continue;
}
used[i]=1;
if(dfs(d+1))return true;
used[i]=0;
}
return false;
}
int main()
{
cin>>T;
for(int i=1;i<=T;i++)
{
memset(used,0,sizeof(used));
for(int i=0;i<7;i++)
{
a[i].scan();
}
printf("Case %d: ",++stamp);
if(!dfs(0))
{
cout<<"No solution"<<endl;
}
}
return 0;
}

#### gym101498

2017-10-07 21:37:52

#### Gym小记（一）

2017-10-26 15:55:10

#### ubuntu 安装python gym

2017-07-08 15:06:31

#### OpenAI Gym 入门与提高（一） Gym环境构建与最简单的RL agent

2017-04-22 00:36:17

#### 在gym中注册自己的模拟器

2018-02-28 15:39:44

#### 增强学习和OpeAI Gym的介绍：基础增强学习问题的演示

2017-10-13 00:00:00

#### OpenAI_gym的官网案例

2017-11-23 08:46:23

#### Gym - 101617H（Security Badges）

2017-12-08 16:40:54

#### Gym小记（七）

2017-11-01 16:17:45

#### ubuntu14.04下anaconda安装openai_gym

2017-08-06 21:43:56