atcoder#ABC250C. [ABC250C] Adjacent Swaps
[ABC250C] Adjacent Swaps
Score : points
Problem Statement
balls are lined up in a row from left to right. Initially, the -th () ball from the left has an integer written on it.
Takahashi has performed operations. The -th () operation was as follows.
- Swap the ball with the integer written on it with the next ball to the right. If the ball with the integer written on it was originally the rightmost ball, swap it with the next ball to the left instead.
Let be the integer written on the -th () ball after the operations. Find .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print , with spaces in between.
5 5
1
2
3
4
5
1 2 3 5 4
The operations are performed as follows.
- Swap the ball with written on it with the next ball to the right. Now, the balls have integers written on them, from left to right.
- Swap the ball with written on it with the next ball to the right. Now, the balls have integers written on them, from left to right.
- Swap the ball with written on it with the next ball to the right. Now, the balls have integers written on them, from left to right.
- Swap the ball with written on it with the next ball to the right. Now, the balls have integers written on them, from left to right.
- Swap the ball with written on it with the next ball to the left, since it is the rightmost ball. Now, the balls have integers written on them, from left to right.
7 7
7
7
7
7
7
7
7
1 2 3 4 5 7 6
10 6
1
5
2
9
6
6
1 2 3 4 5 7 6 8 10 9