The Game
Memory limit: 32 MB
The board consists of numbered fields.
There are black and white pawns.
The black pawns are located on first fields of the board (the fields numbered from 1 to ),
whereas the white pawns are located on the last fields (the fields numbered from to ).
Initially, only the -th field is empty.
a. the initial configuration of pawns on the board for and possible moves of the pawns
b. the board after moving the white pawn from the field number 5 and possible moves of the pawns
During the game, two types of moves can be performed. The first one is a shift of a pawn to the adjacent
free field. The second move - jump, consists of jumping over a single adjacent pawn of a different colour and
landing on the free field.
The goal of the game is to exchange the positions of white and black pawns.
In the other words, the black pawns have to be moved to the fields numbered from to ,
while the white pawns should be moved to the fields numbered from 1 to .
Find the shortest sequence of moves which accomplishes the goal of the game.
Task
Write a program, which:
- reads a number denoting the number of white and black pawns,
- determines the shortest sequence of moves leading to the goal of the game,
- writes the answer.
Input
The first and only line of standard input contains a single integer ().
Output
The first line of standard output should contain number denoting the minimal length
of a sequence of moves leading to the goal of the game.
Each of the following lines should contain one integer from the range .
Integer from the line number (for ) defines the number of
the field, from which the pawn is being moved during -th move.
If there are many possible solutions, your program can output any of them.
Example
For the input data:
1
the correct result is:
3
1
3
2
Task author: Tomasz Idziaszek.