background Background
Due to the talent of talent123, when talent123 done Noip test two times two to check the number of squares and vijos in the three-square number, the whim ....
Title Description Description
In a wide m, long N-n matrix, please make a program, n n times from the upper left corner of the matrix to the bottom right corner of the matrix, each to a place, take away the number of the place, please choose a
The seed-going method makes the obtained number and maximum, and outputs its maximum value. of which: 3<=m<=20,m<=n<=100,1<=n<=10 3
such as input data:
3 10 13
0 1 2 3 4 9 7 1 3 1
9 1 2 2 3 6 7 8 1 2
1 2 3 4 5 9 8 7 6 1
9 7 1 3 1 9 1 2 2 3
6 7 8 1 2 1 2 3 4 5
9 1 2 2 3 6 7 8 1 2
1 2 3 4 5 9 8 7 6 1
9 7 1 3 1 9 1 2 2 3
6 7 8 1 2 1 2 3 4 5
9 1 2 2 3 6 7 8 1 2
1 2 3 4 5 9 8 7 6 1
9 7 1 3 1 9 1 2 2 3
6 7 8 1 2 1 2 3 4 0
of which n=3,m=10,n=13 n=3,m=10,n=13
That is, when N=3 n=3, it is equivalent to 3 of the number of squares.
For the above data:
Output: 297 297
Note: If you think of a memory-free search method (no matter how you optimize), you can give up the problem directly.
Tip 1: Dynamic planning If you are using a two-bit array, the scale is 100∗100000 100*100000.
Tip 2: If you believe that your program is no longer optimized, there are 2 2 data will still time out, then tell you that there is m<n M in the case of data ...
Enter input
First line: three integers: N,m,n n,m,n
The following n-n rows of M-m numbers per line represent the matrix you want to work with.
Output Outputs
Only one line: the number of the numbers you have achieved.
sample input to sample
4 6 7
0 2 3 4 5 6
6 5 4 3 2 1
0 9 8 7 6 5
12 3 4 5 6 7
0 0 0 1 2 3
12 23 34 45 1 23
4 5 6 6 1 0
sample output Sample outputs
265
Limit Limits
Data range See topic
A total of 10 10 test data, each test data contains 1 1 Test points, each test point time limit of 2 2 seconds.
Time limit:2s 2s & Memory limit:128mb 128MB
Origin Source
This topic from: Beijing, Zhongguancun Middle School, high 39 classes, Sun Yi (Network Name: talent123), Contact: 865383864 (QQ)
This problem is popoqqq in the training, the maximum flow directly on the maximum cost, template water over ...
Idea: To split the building edge, a lattice split into two points, the two points between a flow of 1 1, the weight of matrix[i][j] matrix[i][j] edge, to the surrounding lattice connected to Int_max, the weight of 0 0 edge. At last, the super source S S Direction (N,M) has a flow of n N and a weighted value of 0 0, (the