Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Magic pyramid
Description There are many modifications of the famous Rubic’s Cube puzzle. One of those, called the Magic Pyramid, is based on a tetrahedron instead of the original cube. Faces of the tetrahedron are labeled with the Latin letters Each of the small triangles is painted into one of four distinct colors that we label with the Latin letters • Fig. 1 We can transform the tetrahedron using the operation of ” In addition to rotating the faces, we can also apply the operation of ” p) of the integers 1 to 36. The effect of the operation is that the triangle currently in position _{36}i (according to the numbering given on Figure 1) is re-painted into the color of the triangle currently in position p (according to the same numbering). All 36 triangles are re-painted simultaneously._{i}• Fig. 2 The puzzle is solved if, after applying a number of operations ”rotate a face” and/or ”magic re-paint” all triangles on each face of the tetrahedron have the same color. Write a program to solve the Magic Pyramid puzzle using the minimal possible number of moves. You may assume that all the test cases are solvable in 9 or less moves. Input The first line of the input contains 36 letters ’ The second line of the file contains 36 distinct integers 1…36 that describe the ”magic re-paint” operation. The Output The first and only line of the output should contain a string of characters ’ If there are several solutions with the minimal number of moves, output any one of them. If the puzzle can be solved in no moves at all, output an empty line into the output. Sample Input ddddcccccabbbbbdcaabbbddacccaabddaaa 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Sample Output *U Hint Explanation of the example: Figure 3 shows the initial coloring of the tetrahedron, and Figures 4 and 5 show the results of each operation. The colors of the triangles are given by the following patterns:
Source Northeastern Europe 2005, Western Subregion |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator