编程介的小学生 2017-08-02 04:40 采纳率: 20.5%
浏览 655
已采纳

Rubik's Cube

Problem Description
You are a secret agent for the Eternally Indebted External Intelligence Office (EIEIO) of the country of Nomoneo. Headquarters has disguised your one-time pad for encrypted communications in the form of a Rubik's Cube? (For those of you unfamiliar with the puzzle, a Rubik's Cube?comes in the form of a cube where each face is divided into three rows and three columns (nine "squares". Any of the six faces of the cube may be rotated either clockwise or counterclockwise, which also rotates the three nearest squares on each adjoining face onto a new face, respectively. When solved (or taken from the factory packaging), each face of the cube contains squares of only one color. There is no way to change the relationship between the colors of the central squares on each face.) The cube has been pre-scrambled and you are to apply a certain set of moves to the cube based on the message you want to return.
This diagram provides the relationship between the sides of the cube as well as the orientation of the faces for the purposes of input and output. It should be viewed as an unfolded cube with the text on the outside. The faces are indicated by the color of the central subdivision (square) and are White, Orange, Red, Blue, Green, and Yellow. The corner with the dot is the top left corner for purposes of input and output.

Input
Your program should read the input data from the file, which consists of several cases. The first line of the input will give the number of these input cases (as a decimal integer without any punctuation), which will be greater than or equal to 1 and less than or equal to 10,000. Each case consists of three lines giving the initial state of the puzzle cube and one line giving the rotations you must apply to reach the appropriate final state of the cube.
Each of the three lines giving the initial state of the cube consists of 18 letters with a single space between each pair of letters. There is no space between the last letter and the end of the line. Each of the letters is 'W', 'O', 'R', 'B', 'G', or 'Y' indicating the respective color. The faces are listed from left to right in the order (by central square color) White, Orange, Red, Blue, Green, Yellow. Thus, the first three columns of letters give the state of the "White" face, and so forth.
The fourth line of the case gives the manipulations that you must apply to the cube. Each manipulation consists of a single letter as above ('W', 'O', 'R', 'B', 'G', or 'Y') indicating which face (selected by the color of the center) you should rotate. Each rotation thus indicated is a 90?clockwise rotation of the face with respect to the rest of the cube, looking at the face to be rotated. At least one and no more than 1,000 manipulations will be specified.

Output
Print to standard output the state of the cube after the indicated manipulations. Use the same format as for input: three lines, each containing 18 color letters separated by a single space character. Do not put a space after the final letter on the line. Print out the faces in the same order, left to right, as for input: White, Orange, Red, Blue, Green, Yellow. After each output case, print a line containing 35 '=' characters.

Sample Input
2
W W W O O O R R R B B B G G G Y Y Y
W W W O O O R R R B B B G G G Y Y Y
W W W O O O R R R B B B G G G Y Y Y
RG
Y G G Y G W Y W B R W O R W G B G G
O W R Y O B G R O R B O Y G R B Y Y
O W O G O W Y B W B R W B B O R Y R
GROWBOBGROW

Sample Output
O O O Y Y Y R R R Y Y Y G G G B Y O
W W W O O O R R R B B B G G G B Y O

B B B W W W R R R W W W G G G B Y O

W G R Y B G B R G B O W O R B R W R
G W B G O R G R R Y B B O G O Y Y B

G W R Y Y Y W W O G O W O Y B Y W O

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-16 15:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)