比赛 |
2024暑假C班集训9 |
评测结果 |
AAAATTA |
题目名称 |
矩形覆盖 |
最终得分 |
71 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
2.203 s |
代码语言 |
C++ |
内存使用 |
3.28 MiB |
提交时间 |
2024-07-09 11:37:09 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 5e5+10,inf = 1e8;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n,k;
struct made{
int x = inf,y = inf,xx = -inf,yy = -inf;
}b[10];
struct node{
int x,y;
}a[60];
ll ans = inf;
void dfs(int x){
if(x == n+1){
for(int i = 1;i <= 4;i++)
for(int j = i+1;j <= 4;j++)
if(b[i].x <= b[j].xx && b[i].xx >= b[j].x && b[i].y <= b[j].yy && b[i].yy >= b[j].y)return;
ll s = 0;
for(int i = 1;i <= 4;i++)
if(b[i].x != inf)s += (b[i].xx - b[i].x) * (b[i].yy - b[i].y);
ans = min(ans,s);
return;
}
made now;
for(int i = 1;i <= k;i++){
now = b[i];
b[i].x = min(b[i].x,a[x].x),b[i].xx = max(b[i].xx,a[x].x);
b[i].y = min(b[i].y,a[x].y),b[i].yy = max(b[i].yy,a[x].y);
dfs(x+1);
b[i] = now;
}
}
int main(){
freopen("jxfg.in","r",stdin);
freopen("jxfg.out","w",stdout);
n = read(),k = read();
for(int i = 1;i <= n;i++)a[i].x = read(),a[i].y = read();
dfs(1);
printf("%lld\n",ans);
return cerr<<clock()<<"ms"<<endl,0;
}