Problem 3503 --Mine Sweeper

3503: Mine Sweeper

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $11$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

A mine-sweeper map can be expressed as an r×cgrid, 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 16×30mine-sweeper map, where flag cells denotes mine cells while blank cells denotes non-mine cells with number 0 on them.


Given an integer S, construct a mine-sweeper map of r,cboth not exceeding 25, whose sum of numbers on non-mine cells exactly equals S. If multiple solutions exist, print any one of them. If no solution, print "-1" in one line.
The first line contains one positive integer T(1≤T≤1001), denoting the number of test cases. For each test case:
Input one line containing one integer S(0≤S≤1000).
For each test case:
If no solution, print "-1" in one line.
If any solution exists, print two integers r,c(1≤r,c≤25)in the first line, denoting the size of the mine-sweeper map. Following rlines each contains a string only containing "." or "X" of length cwhere ".", "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.
2
7
128
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.
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.

推荐代码 查看3503 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 梦尘 694388 2020-12-30 21:34:21

赛题来源/所属竞赛 2020 Multi-University Training Contest 10 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛