#P7868. Mine Sweeper(无SPJ)
Mine Sweeper(无SPJ)
Mine Sweeper
Problem Description
A mine-sweeper map can be expressed as an grid, and each cell of the grid is either mine cell or non-mine cell. A mine cell has no number on it, while a non-mine cell has a number, the number of mine cells that share at least one common point with the cell, on it. Following is a mine-sweeper map, where flag cells denotes mine cells while blank cells denotes non-mine cells with number 0 on them.
Given an integer , construct a mine-sweeper map of both not exceeding 25, whose sum of numbers on non-mine cells exactly equals . If multiple solutions exist, print any one of them. If no solution, print "-1" in one line.
Input
The first line contains one positive integer (), denoting the number of test cases. For each test case: Input one line containing one integer .
Output
For each test case: If no solution, print "-1" in one line. If any solution exists, print two integers in the first line, denoting the size of the mine-sweeper map. Following lines each contains a string only containing "." or "X" of length where ".", "X" denote non-mine cells and mine cells respectively, denoting each row of the mine-sweeper map you construct. Please notice that you needn't print the numbers on non-mine cells since these numbers can be determined by the output mine-sweeper map.
Sample Input
2
7
128
Sample Output
2 4
X..X
X...
5 19
.XXXX..XXXXX..XXXX.
XX.......X....X..XX
X........X....XXXX.
XX.....X.X....X..XX
.XXXX...XX....XXXX.
Hint
For the first test case, the map with numbers is as follows: X21X X211 The sum of these numbers equals 2+1+2+1+1=7.
Source
2020 Multi-University Training Contest 10