No.3725 Exploit Wall
Problem Statement
Alice and Bob play a game on an $N \times N$ grid. The cell in row $i$ and column $j$ of the grid is denoted by $(i, j)$.
The game proceeds as follows.
- Step $1$. Alice paints each cell of the grid either white or black.
- However, $(1, 1)$ and $(N, N)$ must be painted white.
- At this point, it must not be possible to travel between $(1, 1)$ and $(N, N)$ through white cells.
- Step $2$. Bob chooses exactly one of the following $2$ actions and performs it.
- Choose a pair $(i, j)$ satisfying $2 \leq i \leq j \leq N-1$, and invert the colors (white to black, black to white) of all cells contained in the $j-i+1$ rows from the $i$-th row to the $j$-th row from the top.
- Choose a pair $(i, j)$ satisfying $2 \leq i \leq j \leq N-1$, and invert the colors (white to black, black to white) of all cells contained in the $j-i+1$ columns from the $i$-th column to the $j$-th column from the left.
- Step $3$. If it is possible to travel between $(1, 1)$ and $(N, N)$ through white cells, Alice wins. Otherwise, Bob wins.
Does there exist a way of painting the grid in Step $1$ such that Alice wins the game no matter how Bob acts? If one exists, output one example of such a painting. If none exists, output -1.
Here, "it is possible to travel between $(1, 1)$ and $(N, N)$ through white cells" means that cell $(N, N)$ can be reached from cell $(1, 1)$ by repeatedly moving to a white cell adjacent vertically or horizontally.
Constraints
- All input values are integers.
- $3 \leq N \leq 100$
Input
The input is given from Standard Input in the following format.
$N$
Output
If a painting satisfying the conditions exists, output one example of it in the following format. Here, $S_i\ (1 \leq i \leq N)$ is a string of length $N$, and the $j$-th character of $S_i$ must be . if the cell in the $i$-th row from the top and the $j$-th column from the left is painted white, and # if it is painted black. If no painting satisfying the conditions exists, output -1.
$S_1$ $S_2$ $\vdots$ $S_N$
Print a newline at the end.
Visualizer
A web-based visualizer for the output is available here.
During the contest, sharing visualization results and mentioning solutions or insights are prohibited. Please be careful.
In principle, questions about the specifications of the visualizer will not be accepted. Please use it only as an auxiliary tool.
Sample
Sample 1
Input
3
Output
.#. ### .#.
The operations Bob can perform are either inverting the color of each cell in row $2$ or inverting the color of each cell in column $2$. Whichever he performs, it becomes possible to travel between $(1, 1)$ and $(N, N)$ through white cells.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。