Leapin ' lizardsTime
limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1531 Accepted Submission (s): 623
Problem Descriptionyour platoon of wandering Lizards has entered a strange the The labyrinth. As you is looking around for hidden treasures, one of the rookies steps in an innocent-looking stone and the the "s floor Suddenly disappears! Each lizard in your platoon are 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 the-the-same, and report the number of casualties.
The pillars in the class is aligned as a grid, with each pillar one unit away from the pillars to it east, west, north an D South. Pillars at the edge of the grid is one unit away from the edge of the The (safety). Not all pillars necessarily has a lizard. A Lizard is able to leap onto any unoccupied pillar the is within D units of he current one. A lizard standing on a pillar within leaping distance of the edge of the the-the-the-all leap to safety ... but there ' s a C Atch:each pillar becomes weakened after each jump, and would 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-pillar at any given time.
Inputthe input file would begin with a line containing a single integer representing the number of test cases, which are at Most 25. Each test case would begin with a line containing a single positive an integer n representing the number of rows in the map, F Ollowed by a single non-negative integer d representing the maximum leaping distance for the lizards. Both maps would follow, each as a map of characters with one row per line. The first map would contain a digit (0-3) in each position representing the number of jumps the pillar in that position wil L Sustain before collapsing (0 means there is no pillar there). The second map would follow, with a ' L ' for every position where a lizard are on the pillar and a '. ' For every empty Pilla R. There'll never be a lizard to a position where there is no pillar. Each input map was 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.
Outputfor each input case, print a single line containing the number of lizards this could not escape. The format should follow the samples provided below.
Sample Input
1111111111111llllllllllll3 2000000111000000......LLL ... 3 1000000111000000......LLL ... 5 20000000002000000003211000200000000000000..................LLLL ......... .....
Sample Output
Case #1:2 lizards were left behind. Case #2: No lizard is left behind. Case #3:3 Liz
hdu2732leapin& #39; Lizards (Max stream SAP, Map---vertex method)