No.1434 Make Maze
タグ : / 解いたユーザー数 54
作問者 :
Problem Statement
There is a grid with $H$ rows and $W$ columns ( $H,W$ are odd). The cell in the $i$-th row from the top and the $j$-th column from the left is called cell $(i,j)$.
Chawanmushi-kun is at cell $(1,1)$. He will now travel to cell $(H,W)$ by repeatedly moving to a cell without an obstacle that is adjacent vertically or horizontally.
Before Chawanmushi-kun starts moving, you may place as many obstacles on cells as you like. However, the placement of obstacles must satisfy the following conditions.
- No obstacle is placed on any cell $(i,j)$ where $i,j$ are both odd.
- An obstacle is placed on every cell $(i,j)$ where $i,j$ are both even.
- For any $2$ distinct cells without obstacles, there exists exactly one path along which Chawanmushi-kun can move between those $2$ cells without passing through the same cell $2$ or more times.
For example, the placement of obstacles in the following figure satisfies the conditions.
On the other hand, the placement of obstacles in the following figure does not satisfy the conditions.
Place obstacles so that the minimum number of moves Chawanmushi-kun needs to reach cell $(H,W)$ is $X$.
Constraints
- All inputs are integers
- $3 \le H,W \le 10^3$
- $H,W$ are odd
- $1 \le X \le HW$
Input
The input is given from standard input in the following format.
$H\ W\ X$
Output
If no placement satisfying the conditions exists, output -1.
Otherwise, output $H$ lines, each containing a string of length $W$ consisting of .,#.
If you place an obstacle on cell $(i,j)$, the $j$-th character of the $i$-th line must be #; otherwise, it must be ..
Print a newline at the end.
Sample
Sample 1
Input
5 7 18
Output
...#... ##.#.## ...#... .###.#. .....#.
With this placement of obstacles, Chawanmushi-kun can reach cell $(H,W)$ by making $18$ moves.
Also, no condition is violated, so this output is correct.
Sample 2
Input
11 11 121
Output
-1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。