当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6879:Mine Sweeper

Special Judge 特殊评判
题目描述
A mine-sweeper map can be expressed as an $r\times c$ 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 $16\times 30$ mine-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, c$ both 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\le T \le 1001$), denoting the number of test cases. For each test case:

Input one line containing one integer $S\,(0\le S \le 1000)$.
输出解释
For each test case:

If no solution, print "-1" in one line.

If any solution exists, print two integers $r, c\,(1\le r,c \le 25)$ in the first line, denoting the size of the mine-sweeper map. Following $r$ lines each contains a string only containing "." or "X" of length $c$ 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.
输入样例
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.
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6879

最后修改于 2020-10-25T23:35:11+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)