7995: Painting the Barn 谷仓刷漆

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:9 通过:7

题目描述

农夫约翰不擅长一心多用。

他经常分心,很难完成一些长时间的工作。

目前,他正尝试在谷仓的一侧刷油漆,每次刷漆他都会选取一个矩形区域,并在该区域内涂上一层油漆。

由于需要照顾奶牛让他时常分心,使得油漆涂得并不是很均匀,谷仓的某些部分比其他部分涂有更多层的油漆。

我们可以将谷仓的一侧看作是一个二维 X-Y 平面。

约翰一共刷了 N 次油漆,也就是在这个平面上选取了 N 个矩形区域进行刷漆,每个矩形的边都与坐标轴平行,我们用矩形的左下角和右上角顶点的坐标来描述一个矩形。

约翰想在谷仓的墙壁上多涂几层油漆,这样就不需要在不久的将来再次重新刷漆了。

但是,他又不想浪费时间涂过多的油漆。

结果表明,K 层油漆是最佳用量。

然而,目前恰好涂有 K 层油漆的区域实在是太少了,这让他非常不满意。

因此,他想要多涂两个不相交的矩形(不相交指两个矩形的公共部分面积不大于 00),从而增加恰好涂有 K 层油漆的区域的面积。

当然,他也可以只多涂一个矩形或者不多涂矩形,如果他对目前的涂漆结果满意的话。




Farmer John is not good at multitasking. He gets distracted often, making it hard to complete long projects. Currently, he is trying to paint one side of his barn, but he keeps painting small rectangular areas and then getting sidetracked by the needs of tending to his cows, leaving some parts of the barn painted with more coats of paint than others.

We can describe the side of the barn as a 2D x-y plane, on which Farmer John paints N rectangles, each with sides parallel to the coordinate axes, each described by the coordinates of its lower-left and upper-right corner points.

Farmer John wants to apply several coats of paint to the barn so it doesn't need to be repainted again in the immediate future. However, he doesn't want to waste time applying an excessive number of coats of paint. It turns out that K coats of paint is the optimal amount. However, looking at the amount of area covered by K coats of paint, he is not very happy. He is willing to paint up to two additional rectangles to try and increase this area, as long as these two rectangles are disjoint (not sharing any positive amount of area in common). Note that he can also decide to paint zero new rectangles or just one new rectangle if this ends up being the best thing to do.

INPUT FORMAT (file paintbarn.in):

The first line of input contains N and K (1≤K,N≤105). Each of the remaining N lines contains four integers x1,y1,x2,y2 describing a rectangular region being painted, with lower-left corner (x1,y1) and upper-right corner (x2,y2). All x and y values are in the range 0…200, and all rectangles have positive area.

Like the rectangles he already painted, any new rectangles that Farmer John paints must have positive area, and their corner points must have x and y coordinates in the range 0…200.

OUTPUT FORMAT (file paintbarn.out):

Please output the maximum area of the barn that could be covered by exactly K coats of paint, if Farmer John paints up to two additional disjoint rectangles.

SAMPLE INPUT:

3 2
1 1 4 4
3 3 7 6
2 2 8 7

SAMPLE OUTPUT:

26

输入格式

第一行包含 N 和 K。

接下来 N 行,每行包含四个整数 x1,y1,x2,y2,用来描绘其中一个矩形涂层,该矩形的左下角坐标为 (x1,y1),右上角坐标为 (x2,y2)。

所有 x,y 值都在 0…200范围内,所有矩形的面积均为正。

新涂的两个矩形也要满足点坐标 x,y 值在 0…200范围内,面积必须为正。

输出格式

如果约翰最多再涂两个不相交的矩形区域,请你输出恰好覆盖 K 层油漆的区域的最大可能面积。

数据范围

1≤K,N≤105

输入输出样例

输入 #1复制 



3 2
1 1 4 4
3 3 7 6
2 2 8 7

输出 #1复制 



26

输入样例 复制

3 2
1 1 4 4
3 3 7 6
2 2 8 7

输出样例 复制

26