一开始太蠢,犯迷糊了,以为先确定一个轴再考虑其他的旋转,后来想想,其实只要骰子的3个对面都相同,绕一个轴转肯定可以转回来。
在实现自己的想法的时候,wa了两次,就觉得自己的想法是错的,搜了一下其他人的代码,发现都是穷举,结构体没有学好,不想写那么长,还是自己懒吧,就改了一下,竟然就AC了,好开心。所以只要思路正确,就一直写下去,不要被别人的思想给同化,代码嘛,自己怎么懒,怎么写。
We have a machine for painting cubes. It is supplied with three different colors: blue, red and green. Each face of the cube gets one of these colors. The cube's faces are numbered as in Figure 1.
Figure 1.
Since a cube has 6 faces, our machine can paint a face-numbered cube in different ways. When ignoring the face-numbers, the number of different paintings is much less, because a cube can be rotated. See example below. We denote a painted cube by a string of 6 characters, where each character is a b, r, or g. The
character (
) from the left gives the color of face i. For example, Figure 2 is a picture of rbgggr and Figure 3 corresponds to rggbgr. Notice that both cubes are painted in the same way: by rotating it around the vertical axis by 90
, the one changes into the other.
Input
The input of your program is a textfile that ends with the standard end-of-file marker. Each line is a string of 12 characters. The first 6 characters of this string are the representation of a painted cube, the remaining 6 characters give you the representation of another cube. Your program determines whether these two cubes are painted in the same way, that is, whether by any combination of rotations one can be