P29508 [洛谷] [NWRRC2017] Kotlin Island
入门
题目描述

Problem Description

For a grid of $h$ rows and $w$ columns, each cell is initially "dry".

Your operation can turn all cells in a row or a column into "wet".

Your goal is to leave exactly $n$ connected components of "dry" cells on the grid.

If possible, output a matrix of $h$ rows and $w$ columns.
Use . to represent a "dry" cell and # to represent a "wet" cell.

Otherwise, output a single word Impossible indicating that the goal cannot be achieved.

Input Format

The only line of input contains three integers $h$, $w$, and $n$ -- the height and width of the grid and the desired number of connected components $(1 \le h, w \le 100; 1 \le n \le 10^9)$.

Output Format

If there is no valid plan containing $n$ connected components, output a single word Impossible.

Otherwise, output $h$ lines of length $w$ depicting the plan. Use . to represent a dry land cell and # to represent a water cell.

Sample Input and Output

Sample Input #1

3 5 4

Sample Output #1

..#..
#####
..#..

Sample Input #2

2 1 1

Sample Output #2

#
.

Sample Input #3

5 3 10

Sample Output #3

Impossible

Notes

Time limit: 3 seconds, Memory limit: 512 MB.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 5 4
样例输出
..#.. ##### ..#..