21663_BrickbyBrickGame

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

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

Pro.ID

21663

Title

Brick by Brick Game

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Brick by Brick Game is a kind of creative building game. Like all toy bricks games, it uses a set of bricks to construct buildings.

    In this problem, we consider a set of bricks which forms a building in rectangle shape. Our task is to remove K bricks from the building. In order to make the remaining part of the building keep standing, the following rules should be obeyed:

    (1)  Each floor of the building (remaining part) consists of a single connected row of bricks.

    (2)  At least one brick from each floor must rest upon some brick from the floor below it. The only exception is the bottom floor, which rest upon ground.

    (3)  At least one brick of the bottom floor must be left.

    Each brick has its own visual value (a non-negative integer printed on the surface). We want to maximize the sum of the visual values on the bricks left. Can you tell me what the sum could be?

    For detail, Figure 1 illustrated the case in the sample input. The maximized solution follows all of the above rules. Remember that, there's no restriction on how many floors that the remaining part of the building must keep, so we may abandon some top floors.

    original building                          visual value maximized solution                      

    Figure 1  Example

    输入

    The first line of the input contains a positive integer T ≤ 20 specifying the number of test cases to follow.

    The first line of each case contains three integers: N, M and K. ( 0 < N, M ≤ 64 ,  And max(NM-64, 0) ≤ K < NM )

    Next follow N lines, each with K integers specifying the visual values of each bricks. The first line describes the top floor of the building while the last line describes the bottom floor. All of the visual values are non-negative integers smaller than 32768.

    Numbers are separated by spaces.

    输出

    Description

    Brick by Brick Game is a kind of creative building game. Like all toy bricks games, it uses a set of bricks to construct buildings.

    In this problem, we consider a set of bricks which forms a building in rectangle shape. Our task is to remove K bricks from the building. In order to make the remaining part of the building keep standing, the following rules should be obeyed:

    (1)  Each floor of the building (remaining part) consists of a single connected row of bricks.

    (2)  At least one brick from each floor must rest upon some brick from the floor below it. The only exception is the bottom floor, which rest upon ground.

    (3)  At least one brick of the bottom floor must be left.

    Each brick has its own visual value (a non-negative integer printed on the surface). We want to maximize the sum of the visual values on the bricks left. Can you tell me what the sum could be?

    For detail, Figure 1 illustrated the case in the sample input. The maximized solution follows all of the above rules. Remember that, there's no restriction on how many floors that the remaining part of the building must keep, so we may abandon some top floors.

    original building                          visual value maximized solution                      

    Figure 1  Example

    Input

    The first line of the input contains a positive integer T ≤ 20 specifying the number of test cases to follow.

    The first line of each case contains three integers: N, M and K. ( 0 < N, M ≤ 64 ,  And max(NM-64, 0) ≤ K < NM )

    Next follow N lines, each with K integers specifying the visual values of each bricks. The first line describes the top floor of the building while the last line describes the bottom floor. All of the visual values are non-negative integers smaller than 32768.

    Numbers are separated by spaces.

    Output

    For each test case you should output a single line containing "Case X: Y" (quotes for clarity) where X is the number of the test case (starting at 1) and Y is the total visual value of the maximized solution.

    Sample Input

    1
    6 4 12
    1 1 1 1
    1 7 14 1
    9 4 18 18
    2 4 5 5
    1 7 1 11
    3 2 7 16

    Sample Output

    Case 1: 118

    Source

    样例输入

    1
    6 4 12
    1 1 1 1
    1 7 14 1
    9 4 18 18
    2 4 5 5
    1 7 1 11
    3 2 7 16

    样例输出

    Case 1: 118

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部