# 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;
}

• 本文已收录于以下专栏：

## Ubuntu安装Pyenv+Anaconda2+PyCharm+OpenAI-gym+Cuda+TensorFlow （一）

• GH234505
• 2016年12月28日 18:22
• 3067

## 强化学习仿真环境gym搭建

• qq_36330643
• 2018年01月19日 20:19
• 282

## Gym - 101492 E. Teamwork(过河问题)

• exp1ore
• 2017年08月27日 19:48
• 266

## CodeForces Gym100935 水题专场

CodeForces Gym100935  比赛链接：CodeForces Gym100935 A Time 水题~ #include #include #include #include ...
• ACMore_Xiong
• 2016年08月10日 13:23
• 874

## Fastlane的gym指令

• yyh3663477
• 2017年03月05日 16:38
• 1158

## Gym - 101630C C. Connections

• a15110103117
• 2017年12月09日 16:30
• 95

## OpenAI gym的安装

• lingyun_csdn
• 2018年01月31日 00:04
• 47

## OpenAI Gym使用

OpenAI Gym
• yeqiang19910412
• 2017年09月14日 09:39
• 347

## OpenAI_gym的官网案例

OpenAI_gym的官网案例Tags: openAI_gym创建，渲染，随机选择动作当然这只是gym的一个游戏，还有一些如： MountainCar-v0, MsPacman-v0 (require...
• Charel_CHEN
• 2017年11月23日 08:46
• 304

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

• zkh880loLh3h21AJTH
• 2017年10月13日 00:00
• 597

举报原因： 您举报文章：100642D GYM 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)