P1259 Movement of Black and White Pieces

Background

# Description There are $2n$ pieces arranged in a row. Initially, all white pieces are on the left and all black pieces are on the right. The following figure shows the case $n=5$. ![](https://cdn.luogu.com.cn/upload/image_hosting/dzfwand6.png) The rules for moving the pieces are as follows: in each move, you must move two adjacent pieces simultaneously, regardless of their colors. They may move left or right into empty positions, but their left–right order cannot be swapped. Each move must jump over one or more pieces (you cannot simply slide). The goal is to obtain a row of pieces alternating in color. For example, when $n=5$, the target becomes: ![](https://cdn.luogu.com.cn/upload/image_hosting/yus9ph6d.png) Task: write a program to print the whole sequence of moves.

Description

There are $2n$ pieces arranged in a row. Initially, all white pieces are on the left and all black pieces are on the right. The following figure shows the case $n=5$. ![](https://cdn.luogu.com.cn/upload/image_hosting/dzfwand6.png) The rules for moving the pieces are as follows: in each move, you must move two adjacent pieces simultaneously, regardless of their colors. They may move left or right into empty positions, but their left–right order cannot be swapped. Each move must jump over one or more pieces (you cannot simply slide). The goal is to obtain a row of pieces alternating in color. For example, when $n=5$, the target becomes: ![](https://cdn.luogu.com.cn/upload/image_hosting/yus9ph6d.png) Task: write a program to print the whole sequence of moves. # Description

Input Format

A single integer $n$.

Output Format

Multiple lines, showing the initial state and the state after each move. Use 'o' to denote a white piece, '*' to denote a black piece, and '-' to denote an empty cell.

Explanation/Hint

Constraints: $4 \leq n \leq 100$. Translated by ChatGPT 5