#P6183. [USACO10MAR] The Rock Game S
[USACO10MAR] The Rock Game S
Description
Before the cows go home to rest and have fun, Farmer John wants them to get some mental exercise by playing a game.
The game board consists of identical holes, and all holes are initially empty. A cow may either cover an empty hole with a rock, or uncover a hole that was previously covered. A game state is defined by which holes are covered by rocks.
The goal of the game is for the cow to reach every possible game state exactly once, and finally return to the initial state.
Here is an example from one of their games (empty holes are shown as O, and holes covered by rocks are shown as X):
| Time | Hole 1 | Hole 2 | Hole 3 | Description |
|---|---|---|---|---|
| O | O | O | At the beginning, all holes are empty | |
| X | Cover hole 3 | |||
| X | Cover hole 1 | |||
| O | Uncover hole 3 | |||
| X | Cover hole 2 | |||
| O | Uncover hole 1 | |||
| X | Cover hole 3 | |||
| X | Cover hole 1 |
Now the cows are stuck and cannot continue. They must uncover a hole, but no matter which hole they uncover, they will reach a state they have already visited. For example, if they remove the rock from the second hole, they will reach the state they already visited at time (X O X).
Below is a valid solution for 3 holes:
| Time | Hole 1 | Hole 2 | Hole 3 | Description |
|---|---|---|---|---|
| O | O | O | At the beginning, all holes are empty | |
| X | Cover hole 2 | |||
| X | Cover hole 3 | |||
| O | Uncover hole 2 | |||
| X | Cover hole 1 | |||
| X | Cover hole 2 | |||
| O | Uncover hole 3 | |||
| O | Uncover hole 2 | |||
| O | Uncover hole 1 and return to the original state |
Now the cows are tired of this game, and they want you to help.
Given , find a valid sequence of states for the game. If there are multiple solutions, output any one of them.
Input Format
Only one line with an integer .
Output Format
Print a total of lines. Each line contains a string of length consisting only of characters O and X. The -th character of the string indicates whether hole is covered or not in that state. The first and last lines must both be all O.
3
OOO
OXO
OXX
OOX
XOX
XXX
XXO
XOO
OOO
Hint
Explanation for Sample 1
See the problem description.
Constraints
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号