一道ACM题,求各位大侠帮忙。这是12年山东浪潮杯的一道题,题目如下: Mine Number

链接:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2410&cid=1176
Mine Number
Time Limit: 1000MS Memory limit: 65536K
题目描述
Every one once played the game called Mine Sweeping, here I change the rule. You are given an n*m map, every element is a '*' representing a mine, or a '.' representing any other thing. If I ask you what's the total number of mines around (i, j), you should check (i, j)'s up, down, left, right and also itself (if overstep the boundary, ignore it), if that position is a '*', you should add one to the total number of (i, j), and here I call the number Mine Number. For example, if the map is "..**.. ", we can get the Mine Number as "012210" easily, but here is the question, if I give you the Mine Number, can you tell me the original map?

输入
The input consists of multiple test cases.
The first line contains a number T, representing the number of test cases.
Then T lines follow. For each case, the first line contains two numbers n and m (1<=n, m<=20).representing the lines and rows. Then following n lines, each line contain m numbers each number represents the Mine Number.
输出
For each case, please print the case number (beginning with 1) and the original map which you reverted. The data guarantee there is only one result.
示例输入
27 11100101001012122322122232354532323323555323233123532133321022201333100010001115 6001110013431014541013431001110

示例输出
Case 1:...........*..*.*..*.**.*****.*.**.*****.*.**..***..*.**...*...***...........Case 2:........***...***...***.......
输出结果有点看不清,还是到原网页去看一下比较清晰。
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2410&cid=1176

先把所有的0填出来 ,然后再1.。1的话,有9个选择,由于已经有0的填上了,所以能排除些,再在剩余的位置假设1填入,再回溯吧。

先把0的位置填上,再遍历,看下,找到哪些周围没填上的个数==这个点的数值,直到没有找到,这时再回溯
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜