21199_LeapingLizards

2022-5-16 18:18| 发布者: Hocassian| 查看: 45| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-895058775600-Problem List-采集的数据-后羿采集器.html

Pro.ID

21199

Title

Leaping Lizards

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21199

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 9000/3000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    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...

    The Problem

    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.

    输入

    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 * m, where 1 <= n <= 20 and 1 <= m <= 20.
    • Leaping distance is guaranteed to be in the range [1, 4].

    输出

    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...

    The Problem

    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 * m, where 1 <= n <= 20 and 1 <= m <= 20.
    • Leaping distance is guaranteed to be in the range [1, 4].
    Output
    For each input case, you should return the number of lizards that could not escape. There should be a newline after each case, and your output format should follow the sample 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.
    Source

    样例输入

    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..
    ........
    ........

    样例输出

    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.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部