#T384. 矩阵取数游戏
矩阵取数游戏
Here's the translation of the provided Chinese text into English while preserving all formatting:
## Description
Shuai Shuai often plays a matrix number-taking game with his classmates: Given an n*m matrix, each element a~ij~ in the matrix is a non-negative integer.
The game rules are as follows:
1. Each time numbers are taken, one element must be taken from each row, totaling n elements. All elements of the matrix are taken after m turns;
2. The elements taken each time can only be from the start or the end of their respective rows;
3. Each number-taking operation has a score value, which is the sum of the scores from each row. The score for taking a number from a row = the value of the taken element * 2^i, where i represents the i-th turn of number-taking (starting from 1);
4. The total score at the end of the game is the sum of the scores from all m turns of number-taking.
Shuai Shuai wants you to write a program that can calculate the maximum possible score after number-taking for any given matrix.
## Input Format
The input consists of n+1 lines:
The first line contains two integers n and m separated by a space.
Lines 2 to n+1 represent the n*m matrix, where each line contains m non-negative integers separated by single spaces.
## Output Format
The output consists of n+1 lines:
The first line contains two integers n and m separated by a space.
Lines 2 to n+1 represent the n*m matrix, where each line contains m non-negative integers separated by single spaces.
Note: The Output Format section appears to be identical to the Input Format section in the original text. If this is unintended, please verify the correct output format requirements.
2 3
1 2 3
3 4 2
82
Hint
Sample Explanation
1st Round: Take the first element from the first row and the last element from the second row. The score for this round is 1 * 2^1 + 2 * 2^1 = 6.
2nd Round: Take the first element from both rows. The score for this round is 2 * 2^2 + 3 * 2^2 = 20.
3rd Round: The score is 3 * 2^3 + 4 * 2^3 = 56. The total score is 6 + 20 + 56 = 82.
Data Range
- For 60% of the data: 1 ≤ n, m ≤ 30, and the answer does not exceed 10^16.
- For 100% of the data: 1 ≤ n, m ≤ 80, 0 ≤ a_ij ≤ 1000.
Source
NOIP2007-S3