No.3733 My First Grid
Story
This problem was created in month $3$ of the year $2023$, and it is the first grid construction problem I ever wrote.
For this contest, I adjusted the difficulty and the format, but the solution is almost unchanged.
Problem Statement
There is a board with $H$ rows and $W$ columns.
Each cell of the board is painted white or black. Is it possible to paint the board so that the following $3$ conditions are satisfied?
- All white cells are connected (from any white cell $x$ to any white cell $y$, one can move by passing only through white cells that are vertically or horizontally adjacent)
- All black cells are connected (from any black cell $x$ to any black cell $y$, one can move by passing only through black cells that are vertically or horizontally adjacent)
- There are exactly $K$ places where a white cell and a black cell are vertically or horizontally adjacent
If it is possible, output an example of such a board. If it is impossible, report that.
Constraints
- All inputs are integers
- $1 \leq H \leq 1000$
- $1 \leq W \leq 1000$
- $2 \leq HW$
- $0 \leq K \leq 2HW - H - W$
Input
The input is given from standard input in the following format.
$H\ W\ K$
Output
If a board satisfying the conditions of the problem exists, output $1$ example of such a board. If none exists, output -1.
Output the board in the format below, where, if the cell at row $i$, column $j$ of the board is black, the $j$-th character of $S_i$ is #, and if it is white, the $j$-th character of $S_i$ is .. See also Sample $1$.
$S_1$ $S_2$ $\vdots$ $S_H$
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 observations are prohibited. Please be careful.
In addition, questions about the specifications of the visualizer are in principle not accepted. Please use it only as a supplementary tool.
Sample
Sample 1
Input
3 3 5
Output
.#. .#. ...
All white cells are connected, all black cells are connected, and there are $5$ places where a black cell and a white cell are vertically or horizontally adjacent, so the conditions of the problem are satisfied.
Sample 2
Input
2 2 1
Output
-1
Sample 3
Input
3 4 0
Output
#### #### ####
Note that even when all cells are painted black, all white cells are considered to be connected.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。