A10152 | Edo and Magnets
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Edo has got a collection of $n$ refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be positive integers.
Edo figured out how he wants to place the magnets on the refrigerator. He introduced a system of coordinates on the plane, where each magnet is represented as a rectangle with sides parallel to the coordinate axes.
Now he wants to remove no more than $k$ magnets (he may choose to keep all of them) and attach all remaining magnets to the refrigerator door, and the area of the door should be as small as possible. A magnet is considered to be attached to the refrigerator door if its center lies on the door or on its boundary. The relative positions of all the remaining magnets must correspond to the plan.
Let us explain the last two sentences. Let's suppose we want to hang two magnets on the refrigerator. If the magnet in the plan has coordinates of the lower left corner ( $x_{1}$ , $y_{1}$ ) and the upper right corner ( $x_{2}$ , $y_{2}$ ), then its center is located at (, ) (may not be integers). By saying the relative position should correspond to the plan we mean that the only available operation is translation, i.e. the vector connecting the centers of two magnets in the original plan, must be equal to the vector connecting the centers of these two magnets on the refrigerator.
The sides of the refrigerator door must also be parallel to coordinate axes.
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be positive integers.
Edo figured out how he wants to place the magnets on the refrigerator. He introduced a system of coordinates on the plane, where each magnet is represented as a rectangle with sides parallel to the coordinate axes.
Now he wants to remove no more than $k$ magnets (he may choose to keep all of them) and attach all remaining magnets to the refrigerator door, and the area of the door should be as small as possible. A magnet is considered to be attached to the refrigerator door if its center lies on the door or on its boundary. The relative positions of all the remaining magnets must correspond to the plan.
Let us explain the last two sentences. Let's suppose we want to hang two magnets on the refrigerator. If the magnet in the plan has coordinates of the lower left corner ( $x_{1}$ , $y_{1}$ ) and the upper right corner ( $x_{2}$ , $y_{2}$ ), then its center is located at (, ) (may not be integers). By saying the relative position should correspond to the plan we mean that the only available operation is translation, i.e. the vector connecting the centers of two magnets in the original plan, must be equal to the vector connecting the centers of these two magnets on the refrigerator.
The sides of the refrigerator door must also be parallel to coordinate axes.
输入格式
The first line contains two integers $n$ and $k$ ( $1<=n<=100000$ , $0<=k<=min(10,n-1)$ ) — the number of magnets that Edo has and the maximum number of magnets Edo may not place on the refrigerator.
Next $n$ lines describe the initial plan of placing magnets. Each line contains four integers $x_{1},y_{1},x_{2},y_{2}$ ( $1<=x_{1}<x_{2}<=10^{9}$ , $1<=y_{1}<y_{2}<=10^{9}$ ) — the coordinates of the lower left and upper right corners of the current magnet. The magnets can partially overlap or even fully coincide.
Next $n$ lines describe the initial plan of placing magnets. Each line contains four integers $x_{1},y_{1},x_{2},y_{2}$ ( $1<=x_{1}<x_{2}<=10^{9}$ , $1<=y_{1}<y_{2}<=10^{9}$ ) — the coordinates of the lower left and upper right corners of the current magnet. The magnets can partially overlap or even fully coincide.
输出格式
Print a single integer — the minimum area of the door of refrigerator, which can be used to place at least $n-k$ magnets, preserving the relative positions.
输入输出样例
输入 #1
3 1 1 1 2 2 2 2 3 3 3 3 4 4
输出 #1
1
输入 #2
4 1 1 1 2 2 1 9 2 10 9 9 10 10 9 1 10 2
输出 #2
64
输入 #3
3 0 1 1 2 2 1 1 1000000000 1000000000 1 3 8 12
输出 #3
249999999000000001
In the first test sample it is optimal to remove either the first or the third magnet. If we remove the first magnet, the centers of two others will lie at points (2.5, 2.5) and (3.5, 3.5). Thus, it is enough to buy a fridge with door width 1 and door height 1, the area of the door also equals one, correspondingly.
In the second test sample it doesn't matter which magnet to remove, the answer will not change — we need a fridge with door width 8 and door height 8.
In the third sample you cannot remove anything as $k=0$ .
In the second test sample it doesn't matter which magnet to remove, the answer will not change — we need a fridge with door width 8 and door height 8.
In the third sample you cannot remove anything as $k=0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted