22253_TheGameofTetris

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

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

Pro.ID

22253

Title

The Game of Tetris

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Tetris is a famous video game that has 5 pieces similar to these:

    In this problem, you’re given an NxN grid of integers. We want to place a single piece of Tetris on the grid such that the sum of the numbers below the piece are the maximum. Notice that all but the last Tetris piece can be rotated by 90 degrees. Some pieces even have four different orientations. Any orientation is acceptable as long as the piece completely fits inside thegrid. For example, the left-most piece can be placed on the first row of the grid, with a sum of 80. It can also be placed, for example, on the third column, yielding a sum of 91. As a matter of fact, in a 4x4 grid, we can have 77 different ways to place the Tetris pieces. In the sample grid shown onthe right, the largest sum that can be achieved is 120.
    Write a program that determines the largest such sum for a given grid.

    输入

    Your program will be tested on one or more test cases. The first line of a test case has a single integer N denoting the grid size where 4 ≤ N ≤ 100. The grid will be specified using N lines starting on the second line in a row major format. Each line will have N integers separated by one or more spaces. The absolute value of each integer in the grid will not exceed 1, 000, 000.
    The end of the input cases is specified by a zero on a separate line.

    输出

    Description

    Tetris is a famous video game that has 5 pieces similar to these:

    In this problem, you’re given an NxN grid of integers. We want to place a single piece of Tetris on the grid such that the sum of the numbers below the piece are the maximum. Notice that all but the last Tetris piece can be rotated by 90 degrees. Some pieces even have four different orientations. Any orientation is acceptable as long as the piece completely fits inside thegrid. For example, the left-most piece can be placed on the first row of the grid, with a sum of 80. It can also be placed, for example, on the third column, yielding a sum of 91. As a matter of fact, in a 4x4 grid, we can have 77 different ways to place the Tetris pieces. In the sample grid shown onthe right, the largest sum that can be achieved is 120.
    Write a program that determines the largest such sum for a given grid.

    Input
    Your program will be tested on one or more test cases. The first line of a test case has a single integer N denoting the grid size where 4 ≤ N ≤ 100. The grid will be specified using N lines starting on the second line in a row major format. Each line will have N integers separated by one or more spaces. The absolute value of each integer in the grid will not exceed 1, 000, 000.
    The end of the input cases is specified by a zero on a separate line.
    Output
    For each test case, output the result on a single line using the following format:
    k. result
    Where k is the test case number (starting at 1,) and result is the largest sum that can be obtained.
    Sample Input
    4
    70  2  1  7
     7  1 30  6
     4 30 30  5
     3  1 30  2
    0
    Sample Output
    1. 120
    Source

    样例输入

    4
    70  2  1  7
     7  1 30  6
     4 30 30  5
     3  1 30  2
    0

    样例输出

    1. 120

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部