#P2774. 方格取数问题
方格取数问题
Description
There is an -row -column grid, with a positive integer in each cell. You need to pick numbers from the grid so that no two chosen cells share a common edge, and the total sum of the chosen numbers is maximized. Please compute the maximum possible sum.
Input Format
The first line contains two integers separated by a space, representing the number of rows and the number of columns .
From line to line , each line contains integers. The -th integer on line represents the number in the cell at row , column , namely .
Output Format
Output a single integer on one line, representing the maximum sum.
3 3
1 2 3
3 2 3
2 3 1
11
Hint
Constraints
For of the testdata, it is guaranteed that , .
Tip
Please note that in the first line, is read before .
Translated by ChatGPT 5
京公网安备 11011102002149号