| Time Limit: 20000MS | Memory Limit: 65536K | |
| Total Submissions: 134 | Accepted: 13 |
Description
If several solutions exist, the program should find a solution with minimal total costs of these three rectangles. The cost of one rectangle defines as the sum of all the numbers it contains in matrix A.
Input
The first line of each block contains two numbers N and M (1 <= N <= 30, 0 <= M <= N * N) representing the size of the matrix and the maximum area of each rectangle. The second line contains a number C (0 <= C <= N * N), representing the number of '*'s in matrix A. The following C lines each contains two numbers X and Y (1 <= X, Y <= N), representing A[X][Y] (A[X][Y] represents the element in the X-th row and Y-th column)contains a '*'. The following N lines each contains N numbers, representing the matrix A.
Output
Sample Input
5 1 1 0 9 1 1 1 1 1 9 5 6 5 1 1 3 4 4 3 4 5 5 4 5 3 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 2 5 2 1 1 1 2 1 5 3 5 1 1 3 4 4 3 4 5 5 4 5 3 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 2 5 2 1 1 1 2 1 5 2 4 1 1 3 4 4 3 4 5 5 3 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 2 5 2 1 1 1 2 1
Sample Output
0 9 20 23 Impossible
Source
过下面几组数据大概就能过了,就这几种情况
5 6
7
2 2
2 4
3 1
3 3
3 5
4 2
4 4
9 9 9 9 9
9 1 9 1 9
1 1 1 1 1
9 1 9 1 9
9 9 9 9 9
5 6
7
1 3
2 2
2 4
3 3
4 2
4 4
5 3
9 9 1 9 9
9 1 1 1 9
9 9 1 9 9
9 1 1 1 9
9 9 1 9 9
5 3
5
2 2
3 1
3 3
3 5
4 2
9 9 9 9 9
9 1 9 1 9
1 1 1 1 1
9 1 9 1 9
9 9 9 9 9
5 9
6
1 3
2 4
3 1
3 5
4 2
5 3
1 1 1 9 9
1 1 1 1 9
1 1 1 1 1
9 1 1 1 1
9 9 1 1 1
5 9
6
1 3
2 2
3 1
3 5
4 4
5 3
9 9 1 1 1
9 1 1 1 1
1 1 1 1 1
1 1 1 1 9
1 1 1 9 9
矩阵分割求最小成本
301

被折叠的 条评论
为什么被折叠?



