10142 - 时钟

考虑将如此安排在一个 3 x3 行列中的九个时钟:

|-------|    |-------|    |-------|
|       |    |       |    |   |   |
|---O   |    |---O   |    |   O   |
|       |    |       |    |       |
|-------|    |-------|    |-------|
    A            B            C

|-------|    |-------|    |-------|
|       |    |       |    |       |
|   O   |    |   O   |    |   O   |
|   |   |    |   |   |    |   |   |
|-------|    |-------|    |-------|
    D            E            F

|-------|    |-------|    |-------|
|       |    |       |    |       |
|   O   |    |   O---|    |   O   |
|   |   |    |       |    |   |   |
|-------|    |-------|    |-------|
    G            H            I

目标要找一个最小的移动顺序次将所有的指针指向12点。 下面原表格列出了9种不同的旋转指针的方法,每一种方法都叫一次移动。 选择1到9号移动方法,将会使在表格中对应的时钟的指针顺时针旋转90度。

移动方法 受影响的时钟

1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI

Example

9 9 12      9 12 12       9 12 12       12 12 12      12 12 12
6 6 6  5->  9  9  9  8->  9  9  9  4->  12  9  9  9-> 12 12 12
6 3 6       6  6  6       9  9  9       12  9  9      12 12 12

[但这可能不是正确的方法,请看下面]

输入

第1-3行: 三个空格分开的数字,每个数字表示一个时钟的初始时间,3,6,9,12。 数字的含意和上面第一个例子一样。

输出

单独的一行包括一个用空格分开的将所有指针指向12:00的最短移动顺序的列表。 如果有多种方案,输出那种使的连接起来数字最小的方案。(举例来说5 2 4 6 < 9 3 1 1)。

样例

输入

9 9 12
6 6 6
6 3 6

输出

4 5 8 9

提示

The Clocks IOI'94 - Day 2 Consider nine clocks arranged in a 3x3 array thusly:

|-------|    |-------|    |-------|    
|       |    |       |    |   |   |    
|---O   |    |---O   |    |   O   |          
|       |    |       |    |       |           
|-------|    |-------|    |-------|    
    A            B            C

|-------|    |-------|    |-------|
|       |    |       |    |       |
|   O   |    |   O   |    |   O   |
|   |   |    |   |   |    |   |   |
|-------|    |-------|    |-------|
    D            E            F

|-------|    |-------|    |-------|
|       |    |       |    |       |
|   O   |    |   O---|    |   O   |
|   |   |    |       |    |   |   |
|-------|    |-------|    |-------|
    G            H            I

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 spplied 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. Move Affected clocks
1 ABDE
2 ABC
3 BCEF
4 ADG
5 BDEFH
6 CFI
7 DEGH
8 GHI
9 EFHI

Example Each number represents a time accoring to following table:

9 9 12      9 12 12       9 12 12       12 12 12      12 12 12
6 6 6  5->  9  9  9  8->  9  9  9  4->  12  9  9  9-> 12 12 12
6 3 6       6  6  6       9  9  9       12  9  9      12 12 12

[But this might or might not be the 'correct' answer; see below.]

PROGRAM NAME: clocks INPUT FORMAT 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.

SAMPLE INPUT (file clocks.in) 9 9 12 6 6 6 6 3 6

OUTPUT FORMAT 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 OUTPUT (file clocks.out) 4 5 8 9

时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题