Description n points are given on the Cartesian plane. Now you have to use some rectangles whose sides are parallel to the axes to cover them. Every point must be covered. And a point can be covered by several rectangles. Each rectangle should cover at least two points including those that fall on its border. Rectangles should have integral dimensions. Degenerate cases (rectangles with zero area) are not allowed. How will you choose the rectangles so as to minimize the total area of them? Input The input consists of several test cases. Each test cases begins with a line containing a single integer n ( ≤ n ≤ ). Each of the next n lines contains two integers x, y (−, ≤ x, y ≤ ,) giving the coordinates of a point. It is assumed that no two points are the same as each other. A single zero follows the last test case. Output Output the minimum total area of rectangles on a separate line for each test case. Sample Input Sample Output Hint The total area is calculated by adding up the areas of rectangles used. Source
PKU Local 2006, kicc
先预处理数据,将n个点两两组合形成n * (n-1) / 2个矩形,计算每个矩形的面积和内部点个数。 接着利用预处理数据来枚举,定义 dp[S] := 矩形集为S时的最省面积 先假设平面上没有矩形,那么dp[0]=0,接着一个一个地往平面上加矩形,递推关系是: dp[新矩形集合] = min(dp[新矩形集合], dp[旧矩形集合] + 新矩形的面积); #include<iostream> |