22152_Moving

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

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

Pro.ID

22152

Title

Moving

Title链接

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

AC

1

Submit

3

Ratio

33.33%

时间&空间限制

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

    Merlin is moving on a N×N matrix, each cell of the matrix has an integer number. He can go up, down, left or right, but not outside the matrix. His score is the sum of numbers in the visited cell. He can visit a cell more than once, but the number in this cell is still counted only once. Merlin starts at row R, column C, this cell is always considered as a visited cell.

    Write a program to help Merlin get maximum score.

    输入

    Input contains multiple test cases.

    The first line of each test case has three integers: N ( 1 ≤ N ≤ 8 ), R ( 1 ≤ RN ), C ( 1 ≤ CN ).

    Next N lines describe the matrix, each line has N integers in range [-1000, 1000].

    There is a blank line after each test case.

    输出

    Description

    Merlin is moving on a N×N matrix, each cell of the matrix has an integer number. He can go up, down, left or right, but not outside the matrix. His score is the sum of numbers in the visited cell. He can visit a cell more than once, but the number in this cell is still counted only once. Merlin starts at row R, column C, this cell is always considered as a visited cell.

    Write a program to help Merlin get maximum score.

    Input

    Input contains multiple test cases.

    The first line of each test case has three integers: N ( 1 ≤ N ≤ 8 ), R ( 1 ≤ RN ), C ( 1 ≤ CN ).

    Next N lines describe the matrix, each line has N integers in range [-1000, 1000].

    There is a blank line after each test case.

    Output

    Output the maximum score on a single line for each test case.

    Sample Input

    2 1 1
    -10 -20
    -30 -40

    3 2 2
    1 2 3
    -4 5 -10
    7 -10 9

    Sample Output

    -10
    17

    Source

    样例输入

    2 1 1
    -10 -20
    -30 -40

    3 2 2
    1 2 3
    -4 5 -10
    7 -10 9

    样例输出

    -10
    17

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部