# POJ 3422 Kaka's Matrix Travels （最小费用流）

xiaoxiao2021-03-25  26

## Description

On an N × N chessboard with a non-negative number in each grid, Kaka starts his matrix travels with SUM = 0. For each travel, Kaka moves one rook from the left-upper grid to the right-bottom one, taking care that the rook moves only to the right or down. Kaka adds the number to SUM in each grid the rook visited, and replaces it with zero. It is not difficult to know the maximum SUM Kaka can obtain for his first travel. Now Kaka is wondering what is the maximum SUM he can obtain after his Kth travel. Note the SUM is accumulative during the K travels.

## Input

The first line contains two integers N and K (1 ≤ N ≤ 50, 0 ≤ K ≤ 10) described above. The following N lines represents the matrix. You can assume the numbers in the matrix are no more than 1000.

## Output

The maximum SUM Kaka can obtain after his Kth travel.

## Sample Input

3 2 1 2 3 0 2 1 1 4 2

15

## 题意

给出一个 NN 的矩阵，找 k 条从左上角到右下角的路径，然后使得路径上的数字和最大。（寻找路径的时候只能向右或者向下走）

## 思路

和 HDU 3376 一样的题型，只不过 HDU 3376 里面规定只有两条路径，而这里规定有 k 条，然后在建图策略中只需要修改原来矩阵中点到扩充点费用为0的边的容量为k-1即可。

具体请看：HDU 3376 Matrix Again