当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4397:Rubik's Cube

题目描述
Rubik's Cube is a 3-D mechanical puzzle invented in 1974 by Hungarian sculptor and professor of architecture Erno Rubik. Originally called the "Magic Cube", the puzzle was licensed by Rubik to be sold by Ideal Toy Corp. in 1980 and won the German Game of the Year special award for Best Puzzle that year. As of January 2009, 350 million cubes had been sold worldwide making it the world's top-selling puzzle game. It is widely considered to be the world's best-selling toy.
The Rubik's Cube has eight corners and twelve edges. There are 8! (40,320) ways to arrange the corner cubes. Seven can be oriented independently, and the orientation of the eighth depends on the preceding seven, giving 37 (2,187) possibilities. There are 12!/2 (239,500,800) ways to arrange the edges, since an even permutation of the corners implies an even permutation of the edges as well. (When arrangements of centers are also permitted, as described below, the rule is that the combined arrangement of corners, edges, and centers must be an even permutation.) Eleven edges can be flipped independently, with the flip of the twelfth depending on the preceding ones, giving 211 (2,048) possibilities
The total possibilities of a Rubik’s cube are:

Although the number of cases is quite huge, we can still solve the magic cube b some way. It is confirmed that no matter what cases the cube is, you can solve it within just 20 turnings, quite fantastic, isn’t it?
 
A Rubik’s cube has six faces:

F(Front): the side currently facing the solver
B(Back): the side opposite the front
U(Up): the side above or on top of the front side
D(Down): the side opposite the top, underneath the Cube
L(Left): the side directly to the left of the front
R(Right): the side directly to the right of the front

Now, we define several moves which mean different turning of layers: U D R L F B which means turning the up, down, right, lift, front back face clockwise for 90. In addition, use lowercase letters u d r l f b for anticlockwise turnings. Errrrrrrrr, that’s not the end, I define more operations: X Y Z for turning the middle layer (behind U R F) clockwise for 90 Also, lowercase letters x y z for anticlockwise.
There are some examples in the following picture.

As you know that a Rubik’s cube can be solved with several turnings, so we can use the letters mentioned above to representing the solution and a solution is a string containing these lowercase or capital letters. As the string may be very long, so after moving as the string, the cube may return the original status as it begins(completely the same), we define this string as a “meaningless string”.
In this question, we will give you several strings, and you should check whether the string is a “meaningless string” or not.
输入解释
Several cases, each case is a line, contain a string, which length is no more than 200.
You should process the cases until the input reaches EOF.
输出解释
Print “Yes” is after these turnings the cube can return the cases the same as it starts, otherwise print “No”.
Between two cases a blank line must be printed.
输入样例
RRRR
UUDDuudd
RURU
xxxx
输出样例
Yes

Yes

No

Yes
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4397

最后修改于 2020-10-25T23:13:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)