当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2517:Cover

题目描述
Given an N * N matrix A, whose elements are positive integers and not larger than 10000. There are also some '*'s in matrix A. Your program must find such three (perhaps overlapping) rectangles that they would contain all the '*'s which are in matrix A and the areas of these three rectangles (the area of one rectangle define as the number of elements it covers) must be non-negative and not exceed a given integer M.

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.
输入解释
The first line of the input is an integer X representing the number of test cases. The following X blocks each represents a test case.

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.
输出解释
For each block output one line, which contains an integer representing the minimum total costs, or 'Impossible' (without quote) if no solution exists.
输入样例
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
输出样例
0
9
20
23
Impossible

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2517

最后修改于 2020-10-29T06:34:41+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000 65536