Pro.ID22152 TitleMoving Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22152 AC1 Submit3 Ratio33.33% 时间&空间限制描述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 ≤ R ≤ N ), C ( 1 ≤ C ≤ N ). 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 ≤ R ≤ N ), C ( 1 ≤ C ≤ N ). 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 Sample Output -10 Source 样例输入2 1 1 样例输出-10 作者 |