#P4474. 王者之剑

王者之剑

Description

https://cdn.luogu.com.cn/upload/pic/17920.png

This is before Artoria Pendragon became a Heroic Spirit. She is about to pull the sword from the stone to become King Arthur, and before that she needs to collect some gems.

The gems are arranged in an n×mn \times m grid. Each cell contains a gem worth vi,jv_{i,j}. Artoria Pendragon may choose her own starting cell.

The initial time is 00 seconds. The following operations are executed every second, in order.

  1. At the beginning of second ii, if Artoria Pendragon is on cell (x,y)(x, y), she can take the gem in (x,y)(x, y).
  2. At even-numbered seconds, the gems in the four orthogonally adjacent cells around Artoria Pendragon disappear.
  3. If Artoria Pendragon is on cell (x,y)(x, y) at the beginning of second ii, then at second i+1i+1 she may immediately move to (x+1,y)(x+1, y), (x,y+1)(x, y+1), (x1,y)(x-1, y), or (x,y1)(x, y-1), or stay at (x,y)(x, y).

Find the maximum total value of gems that Artoria Pendragon can obtain.

Input Format

The first line gives the numbers N,MN, M, representing the number of rows and columns. N,M100N, M \le 100. The value of each gem does not exceed 1000010000. The next NN lines and MM columns describe the value matrix.

Output Format

Output the maximum total value of gems that can be taken.

2 2
1 2
2 1
4

Hint

An original problem by Yao Jinyu.

Translated by ChatGPT 5