Pro.ID10118 TitleThe Clocks Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10118 AC43 Submit322 Ratio13.35% 时间&空间限制描述Consider nine clocks arranged in a 3×3 array thusly: |-------| |-------| |-------| The goal is to find a minimal sequence of moves to return all the dials to 12 o'clock. Nine different ways to turn the dials on the clocks are supplied via a table below; each way is called a move. Select for each move a number 1 through 9 which will cause the dials of the affected clocks (see next table) to be turned 90 degrees clockwise.
Each number represents a time accoring to following table: 9 9 12 9 12 12 9 12 12 12 12 12 12 12 12 [But this might or might not be the 'correct' answer; see below.] 输入Multiple test cases, first line is an integer T, indecating the number of test cases. Each case has three lines: Lines 1-3: Three lines of three space-separated numbers; each number represents the start time of one clock, 3, 6, 9, or 12. The ordering of the numbers corresponds to the first example above. 输出Description Consider nine clocks arranged in a 3×3 array thusly: |-------| |-------| |-------| The goal is to find a minimal sequence of moves to return all the dials to 12 o'clock. Nine different ways to turn the dials on the clocks are supplied via a table below; each way is called a move. Select for each move a number 1 through 9 which will cause the dials of the affected clocks (see next table) to be turned 90 degrees clockwise.
Each number represents a time accoring to following table: 9 9 12 9 12 12 9 12 12 12 12 12 12 12 12 [But this might or might not be the 'correct' answer; see below.] Input Multiple test cases, first line is an integer T, indecating the number of test cases. Each case has three lines: Lines 1-3: Three lines of three space-separated numbers; each number represents the start time of one clock, 3, 6, 9, or 12. The ordering of the numbers corresponds to the first example above. Output For each test case, output : A single line that contains a space separated list of the shortest sequence of moves (designated by numbers) which returns all the clocks to 12:00. If there is more than one solution, print the one which gives the lowest number when the moves are concatenated (e.g., 5 2 4 6 < 9 3 1 1). Sample Input 2 Sample Output 4 5 8 9 Source 样例输入2 样例输出4 5 8 9 作者 |