Problem Statement
Rabbit 和 Eel 在玩一个游戏.
游戏在一个 n * m 的棋盘上进行,
在这个游戏中, 玩家需要操作一个棋子, 将它从第一行移动到最后一行(当棋子被移动到最后一行时, 游戏立刻结束).
在第 i 行第 j 列有一个数字 a[i][j], 表示经过这个格子的代价.
游戏由若干轮组成. 每一轮由 Rabbit 先操作. 在第一轮, Rabbit 会把一个棋子放在第一行的某一列上, 并付出相应的费用.
在接下来的每一轮中, Rabbit 先把棋子向左, 向右, 或向下移动一步, 然后付出相应的费用.
然后由 Eel 操作. Eel 可以选取一对 (i, j), 其中 1 <= i < n 并且 1 <= j < m, 然后在 (i, j) 和 (i + 1, j) 之间修建一堵墙.
Eel 每次操作可以修建任意多的墙, 但是在任意时刻, Eel 修建的墙都不能够使游戏无法结束
(也就是说, Eel 修建的墙不能阻止棋子从当前的位置移动到最后一行).
Rabbit 的目标是最小化花费, 而 Eel 的目标是最大化 Rabbit 的花费. 现在假设双方都绝顶聪明, 你需要求出最后的花费.
注意: 多次经过同一个位置的花费算 多次 .
1 <= n, m <= 50, 0 <= a[i][j] <= 9.
Rabbit and Eel are playing a board game.
The game is played with a single token on a rectangular board that is divided into a grid of unit cells.
Each cell contains a digit that represents the cost of placing the token onto that cell.
The game is played in turns.
In each turn, Rabbit moves first and Eel moves second.
In the first turn, Rabbit places the token onto one of the cells in the topmost row, and he pays the associated cost.
In each of the following turns, Rabbit moves the token one cell left, right, or down, and pays the cost written in the target cell.
(Note that Rabbit is not allowed to move the token upwards.)
Eel never moves the token.
Instead, in each turn, Eel gets to place some walls.
In each turn, Eel may place as many walls as he wants, including none.
Each wall must be placed between two adjacent cells in the same column.
The game ends when Rabbit first moves the token into the bottommost row.
The game must always be allowed to end.
That is, Eel must never place a wall that would prevent Rabbit from reaching the bottommost row from the token's current location.
Rabbit's goal is to minimize and Eel's goal is to maximize the total cost paid by Rabbit during the game.
You are given the String[] costs representing the costs of cells:
character j of element i of cost represents the cost written in the cell in row i, column j.
Return the total cost of the game assuming that both Rabbit and Eel play optimally.