#T378. 传纸条
传纸条
Description
Xiao Yuan and Xiao Xuan are good friends and classmates who always have endless topics to discuss.
During a team-building activity, their classmates were arranged in a matrix with m rows and n columns, while Xiao Yuan and Xiao Xuan were placed at opposite ends of the matrix's diagonal, making direct conversation impossible.
Fortunately, they can communicate by passing notes. The notes must be relayed through many classmates. Xiao Yuan sits at the top-left corner of the matrix, coordinates (1, 1), and Xiao Xuan sits at the bottom-right corner, coordinates (m, n). Notes passed from Xiao Yuan to Xiao Xuan can only move downward or to the right, while notes passed from Xiao Xuan to Xiao Yuan can only move upward or to the left.
During the activity, Xiao Yuan wants to send a note to Xiao Xuan and also hopes to receive a reply. Each classmate can help relay the note, but only once—meaning if someone helps when passing the note from Xiao Yuan to Xiao Xuan, they won't help again when passing the note from Xiao Xuan to Xiao Yuan, and vice versa.
Another thing to note is that each classmate has a varying level of willingness to help (note: the willingness levels of Xiao Yuan and Xiao Xuan are not defined and are represented as 0 in the input), which can be represented by a natural number between 0 and 100. The higher the number, the more willing they are to help. Xiao Yuan and Xiao Xuan want to maximize the total willingness level of the classmates involved in the two-way note-passing, i.e., to find two paths (one for each direction) such that the sum of the willingness levels along these paths is maximized. Your task is to help them find such two paths.
Input Format
The first line contains two integers m and n separated by a space, representing the number of rows and columns in the class matrix (1 ≤ m, n ≤ 50).
The next m lines form an m × n matrix, where the integer in the i-th row and j-th column represents the willingness level of the student sitting at that position. The n integers in each row are separated by spaces.
Output Format
Output a single integer representing the maximum sum of the willingness levels of the students involved in the two-way note-passing paths.
3 3
0 3 9
2 8 5
5 7 0
34
Translation
NOIP2008-S3
(Note: Since the original text only contains "NOIP2008-S3" which appears to be a competition/problem identifier, I've maintained it exactly as is. NOIP stands for National Olympiad in Informatics in Provinces, a Chinese programming competition for secondary school students. The "2008" indicates the year, and "S3" likely refers to either the third problem or the third section of that year's competition.)