Pro.ID21761 TitleFigure ans Spots Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21761 AC0 Submit0 Ratio- 时间&空间限制描述Let's consider an infinite sheet of grid paper. Initially all the cells are white and you can paint some of them black. Two cells are called 8-neighbours if they share a side or a corner. An 8-path between black cells A and B is a sequence of cells X0 = A , X1, ..., XL-1, XL = B such that all cells in the sequence are black and for all 0 ≤ i < L the cells Xi and Xi+1 are 8-neighbours. A set of black cells is called a figure if there is an 8-path from each of them into each other. Two cells are called 4-neighbours if they share a side. A 4-path between white cells A and B is a sequence of cells X0 = A, X1, ..., XL-1 , XL = B such that all cells in the sequence are white and for all 0 ≤ i < L the cells Xi and Xi+1 are 4-neigbours. A finite set of white cells is called a spot if:
We say that a figure has the height H and the width W if it fits in a rectangle H rows high and W columns wide, but does not fit in a rectangle H-1 rows high and W columns wide nor in a rectangle H-1 rows high and W columns wide. The image above shows a figure with height 7 and width 9 and containing two spots. Given the numbers H, W and N, construct a figure with height exactly H and width exactly W and containing exactly N spots. 输入The input file contains several test cases. The first line of the file contains T (1 ≤ T ≤ 100), the number of test cases. Each of the following T lines describes one test case and contains three integers H, W and N (1 ≤ H, W ≤ 20, 1 ≤ N ≤ 200), separated by spaces. 输出Description Let's consider an infinite sheet of grid paper. Initially all the cells are white and you can paint some of them black. Two cells are called 8-neighbours if they share a side or a corner. An 8-path between black cells A and B is a sequence of cells X0 = A , X1, ..., XL-1, XL = B such that all cells in the sequence are black and for all 0 ≤ i < L the cells Xi and Xi+1 are 8-neighbours. A set of black cells is called a figure if there is an 8-path from each of them into each other. Two cells are called 4-neighbours if they share a side. A 4-path between white cells A and B is a sequence of cells X0 = A, X1, ..., XL-1 , XL = B such that all cells in the sequence are white and for all 0 ≤ i < L the cells Xi and Xi+1 are 4-neigbours. A finite set of white cells is called a spot if:
We say that a figure has the height H and the width W if it fits in a rectangle H rows high and W columns wide, but does not fit in a rectangle H-1 rows high and W columns wide nor in a rectangle H-1 rows high and W columns wide. The image above shows a figure with height 7 and width 9 and containing two spots. Given the numbers H, W and N, construct a figure with height exactly H and width exactly W and containing exactly N spots. Input The input file contains several test cases. The first line of the file contains T (1 ≤ T ≤ 100), the number of test cases. Each of the following T lines describes one test case and contains three integers H, W and N (1 ≤ H, W ≤ 20, 1 ≤ N ≤ 200), separated by spaces. Output The output file should contain the following data for each test case:
The output data for two different test cases should be separated by an empty line. Sample Input 37 Sample Output #......## Source 样例输入37 样例输出#......## 作者 |