#t293. 拨钟问题
拨钟问题
Clock Puzzle
Problem Background
Special for beginners, ^_^
Problem Description
There are clocks arranged in a matrix:
|-------| |-------| |-------|
| | | | | | |
|---O | |---O | | O |
| | | | | |
|-------| |-------| |-------|
A B C
|-------| |-------| |-------|
| | | | | |
| O | | O | | O |
| | | | | | | | |
|-------| |-------| |-------|
D E F
|-------| |-------| |-------|
| | | | | |
| O | | O---| | O |
| | | | | | | |
|-------| |-------| |-------|
G H I
Now we want to use the minimum number of moves to set all clock hands to the o'clock position. There are different kinds of moves allowed. As shown in the table below, each move rotates the hands of several clocks clockwise.
move clocks affected
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI
Input Format
integers, the starting positions of each clock's hand, separated by single spaces.
Here o'clock, o'clock, o'clock, o'clock.
Output Format
Output a shortest sequence of moves that makes all clock hands point to o'clock. Output the move numbers in increasing order, separated by single spaces.
Sample Input
3 3 0
2 2 2
2 1 2
Sample Output
4 5 8 9
Constraints
Time limit: 1s, memory limit: 1024KiB for each test case.