CF74E.Shift It!
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a square box 6 × 6 in size. It contains 36 chips 1 × 1 in size. Those chips contain 36 different characters — "0"-"9" and "A"-"Z". There is exactly one chip with each character.
You are allowed to make the following operations: you may choose one of 6 rows or one of 6 columns and cyclically shift the chips there to one position to the left or to the right (for the row) or upwards or downwards (for the column). Those operations are allowed to perform several times.
To solve the puzzle is to shift the chips using the above described operations so that they were written in the increasing order (exactly equal to the right picture). An example of solving the puzzle is shown on a picture below.

Write a program that finds the sequence of operations that solves the puzzle. That sequence should not necessarily be shortest, but you should not exceed the limit of 10000 operations. It is guaranteed that the solution always exists.
有一个大小为 6×6 的正方形盒子,其中放置了 36 个大小为 1×1 的方块。这些方块上印有 36 个互不相同的字符:数字 "0"–"9" 和字母 "A"–"Z",每个字符恰好出现一次。
你被允许执行以下操作:任选 6 行中的一行或 6 列中的一列,并将该行(列)上的所有方块向左或向右(对行而言)或向上或向下(对列而言)进行循环移位一个位置。上述操作可重复执行任意多次。
本谜题的目标是通过上述操作,将所有方块调整为按升序排列(即与右侧图示完全一致)。下方图片展示了一个解谜过程的示例。

请编写一个程序,找出一组能解开该谜题的操作序列。该序列不一定是长度最短的,但总操作次数不得超过 10000 次。题目保证解一定存在。
输入格式
The input data are represented by 6 lines containing 6 characters each. They are the puzzle's initial position. Those lines contain each character from the string "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" exactly once.
输入数据由 6 行组成,每行包含 6 个字符,表示谜题的初始状态。这些行中恰好包含字符串 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" 中的每个字符一次。
输出格式
On the first line print number n, which is the number of operations. On the next n lines print the sequence of operations one per line. An operation is described by a word consisting of two characters. The first character shows the direction where the row or the column will be shifted. The possible directions are "L", "R" (to the left, to the right correspondingly, we shift a row), "U", "D" (upwards, downwards correspondingly, we shift a column). The second character is the number of the row (or the column), it is an integer from "1" to "6". The rows are numbered from the top to the bottom, the columns are numbered from the left to the right.
The number of operations should not exceed 104. If there are several solutions, print any of them.
第一行输出一个整数 n,表示操作的次数。接下来的 n 行每行输出一个操作,每个操作由两个字符组成的字符串描述。第一个字符表示移动方向:“L”、“R” 分别表示向左、向右(此时移动的是某一行);“U”、“D” 分别表示向上、向下(此时移动的是某一列)。第二个字符是行号(或列号),为从 "1" 到 "6" 的整数。行号从上到下编号,列号从左到右编号。
操作总数不得超过 104。若存在多种解法,输出任意一种即可。
输入输出样例
输入#1
01W345 729AB6 CD8FGH IJELMN OPKRST UVQXYZ
输出#1
2 R2 U3
输入解题思路,AI测评打分。不知道怎么写?