一个迷宫的便利的典型的算法问题,怎么利用C语言程序代码思路解题的过程?

Problem Description
Your platoon of wandering lizards has entered a strange room in the labyrinth you are exploring. As you are looking around for hidden treasures, one of the rookies steps on an innocent-looking stone and the room's floor suddenly disappears! Each lizard in your platoon is left standing on a fragile-looking pillar, and a fire begins to rage below... Leave no lizard behind! Get as many lizards as possible out of the room, and report the number of casualties.
The pillars in the room are aligned as a grid, with each pillar one unit away from the pillars to its east, west, north and south. Pillars at the edge of the grid are one unit away from the edge of the room (safety). Not all pillars necessarily have a lizard. A lizard is able to leap onto any unoccupied pillar that is within d units of his current one. A lizard standing on a pillar within leaping distance of the edge of the room may always leap to safety... but there's a catch: each pillar becomes weakened after each jump, and will soon collapse and no longer be usable by other lizards. Leaping onto a pillar does not cause it to weaken or collapse; only leaping off of it causes it to weaken and eventually collapse. Only one lizard may be on a pillar at any given time.

Input
The input file will begin with a line containing a single integer representing the number of test cases, which is at most 25. Each test case will begin with a line containing a single positive integer n representing the number of rows in the map, followed by a single non-negative integer d representing the maximum leaping distance for the lizards. Two maps will follow, each as a map of characters with one row per line. The first map will contain a digit (0-3) in each position representing the number of jumps the pillar in that position will sustain before collapsing (0 means there is no pillar there). The second map will follow, with an 'L' for every position where a lizard is on the pillar and a '.' for every empty pillar. There will never be a lizard on a position where there is no pillar.Each input map is guaranteed to be a rectangle of size n x m, where 1 ≤ n ≤ 20 and 1 ≤ m ≤ 20. The leaping distance is
always 1 ≤ d ≤ 3.

Output
For each input case, print a single line containing the number of lizards that could not escape. The format should follow the samples provided below.

Sample Input
4
3 1
1111
1111
1111
LLLL
LLLL
LLLL
3 2
00000
01110
00000
.....
.LLL.
.....
3 1
00000
01110
00000
.....
.LLL.
.....
5 2
00000000
02000000
00321100
02000000
00000000
........
........
..LLLL..
........
........

Sample Output
Case #1: 2 lizards were left behind.
Case #2: no lizard was left behind.
Case #3: 3 lizards were left behind.
Case #4: 1 lizard was left behind.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
QT 迷宫游戏 可视化迷宫
1
问题 C: 孤岛营救问题【队列 搜索 BFS】。
2
vc++写的一个小球迷宫的小游戏,没有错误,但是无法运行,就是打开后显示exe文件无法运行
2
深度优先搜索,迷宫问题,边长大于7*7就运行不出来。
0
C++迷宫(栈实现),无法回溯
1
用java写的迷宫,能够打开自己制定的迷宫地图,并找出最短路径和遍历迷宫
1
骑士游历C语言版,用类似迷宫算法如下,求大神告知错误的地方。
0
用栈解决迷宫问题不知为什么大的例子跑不出
2
c语言走迷宫问题提问!
0
这是我写的迷宫问题的代码,请问各位大神为什么最后输出不了迷宫通路呀
0
用Java做算法提高 学霸的迷宫
0
并查集生成迷宫广度优先搜索最短路径时出现了问题 求大佬解答QAQ很急 拜托了!!!
1
一个数据结构上面路径可达性判断的问题,要求采用C语言技术
0
一个迷宫是否联通的有效性的判定算法怎么实现,采用C语言编程怎么实现
1
BFS走迷宫传送门超时怎么改进啊?
0
迷宫的遍历的算法在数据结构方面的一个运用,怎么采用C程序的语言的技术设计的代码实现?
0
c语言,迷宫问题,救救孩子
2
为什么到最后一直无法输出迷宫路径?
0
迷宫的绕路的一个算法问题,如何运用C语言的程序的编写的方式实现
0
数组走到右上角时可以获得的最大金币数目,请问怎么样才能使用C语言的程序的编写的技术实现的?