关闭

Codeforces Round #330 (Div. 1) C. Edo and Magnets(暴力+矩形覆盖点)

335人阅读 评论(0) 收藏 举报
分类:

题目链接
题意:n个点,可以删除K个点,然后找一个平行于坐标轴的矩形,覆盖所有的点,面积最小
解答:暴力枚举删除4个边界上的点
AAA:码力不足,参考网上



#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back-
#define X first
#define Y second
#define cl(a,b) memset(a,b,sizeof(a))
typedef pair<int,int> P;
const int maxn=300005;
const LL inf=1<<27;
const LL mod=1e9+7;

struct point{
    LL x,y;
}p[maxn];
int x1[maxn],x2[maxn],Y1[maxn],y2[maxn];
///排序
bool cmp1(int a,int b){
    return p[a].x<p[b].x;
}
bool cmp2(int a,int b){
    return p[a].x>p[b].x;
}
bool cmp3(int a,int b){
    return p[a].y<p[b].y;
}
bool cmp4(int a,int b){
    return p[a].y>p[b].y;
}
int used[maxn];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        LL X1,X2,y1,Y2;
        scanf("%lld%lld%lld%lld",&X1,&y1,&X2,&Y2);
        p[i].x=X1+X2;//放大2倍
        p[i].y=y1+Y2;
        x1[i]=x2[i]=Y1[i]=y2[i]=i;
    }

    sort(x1+1,x1+1+n,cmp1);
    sort(x2+1,x2+1+n,cmp2);
    sort(Y1+1,Y1+1+n,cmp3);
    sort(y2+1,y2+1+n,cmp4);

    LL ans=1LL<<62;
    int flag=0;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k;b++){
            for(int c=0;c<=k;c++){
                for(int d=0;d<=k;d++){///暴力枚举
                    flag++;
                    int cnt=0;
                    for(int i=1;i<=a;i++)if(used[x1[i]]!=flag){used[x1[i]]=flag;cnt++;}
                    for(int i=1;i<=b;i++)if(used[x2[i]]!=flag){used[x2[i]]=flag;cnt++;}
                    for(int i=1;i<=c;i++)if(used[Y1[i]]!=flag){used[Y1[i]]=flag;cnt++;}
                    for(int i=1;i<=d;i++)if(used[y2[i]]!=flag){used[y2[i]]=flag;cnt++;}
                    if(cnt!=k)continue;///每次删除k个点
                    LL maxx=-1LL<<62,minx=1LL<<62,maxy=-1LL<<62,miny=1LL<<62;
                    for(int i=1;i<=n;i++)if(used[i]!=flag){
                        maxx=max(p[i].x,maxx);
                        minx=min(p[i].x,minx);
                        maxy=max(p[i].y,maxy);
                        miny=min(p[i].y,miny);
                    }
                    LL x=maxx-minx,y=maxy-miny;
                    if(x%2==1)x++;
                    if(y%2==1)y++;
                    x=max(2LL,x);
                    y=max(2LL,y);
                    ans=min(ans,x*y);
                }
            }
        }
    }
    printf("%lld\n",ans/4);
    return 0;
}
0
0
查看评论

Codeforces Round #254 (Div. 1)C. DZY Loves Colors(线段树经典操作/分块)

题目链接 C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output stan...
  • fouzhe
  • fouzhe
  • 2017-02-11 15:17
  • 283

Codeforces Round #330 (Div. 1) C. Edo and Magnets

题意:给你n个磁块,然后给你一个k。让你求能让n-k个磁块贴在冰箱门上的最小冰箱门面积 贴上去的意思是铁块的中心能放上去(冰箱门是矩形的…. 就等于让你用一个矩形来包括n-k个点 思路:这里观察k比较小 所以我们枚举不要哪k个点就行了 需要注意的就是因为0 ≤ k ≤ min(10, n -...
  • qq_27925701
  • qq_27925701
  • 2016-01-29 17:07
  • 116

Codeforces Round #459 (Div. 2) C. The Monster

题目链接 C. The Monster time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As Will is...
  • ffgcc
  • ffgcc
  • 2018-01-30 09:48
  • 49

Codeforces Round #254 (Div. 1) C. DZY Loves Colors

C. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ...
  • just_sort
  • just_sort
  • 2016-10-03 18:21
  • 359

Codeforces Round #FF (Div. 2) D. DZY Loves Modification 贪心+优先队列

链接:http://codeforces.com/problemset/problem/447/D
  • u011385365
  • u011385365
  • 2014-07-15 15:43
  • 1161

【解题报告】Codeforces Round #367 (Div. 2)

简略的解题报告。
  • TRiddle
  • TRiddle
  • 2016-08-12 21:37
  • 738

Codeforces Round #204 (Div. 1) A. Jeff and Rounding

A. Jeff and Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard out...
  • u010422038
  • u010422038
  • 2013-10-05 08:54
  • 1481

Codeforces Round #214 (Div. 2) C. Dima and Salad (背包变形)

C. Dima and Salad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output...
  • u010228612
  • u010228612
  • 2013-12-10 22:16
  • 1319

Codeforces Round #350 (Div. 2)(C)模拟

C. Cinema time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ...
  • qq_24489717
  • qq_24489717
  • 2016-05-06 15:29
  • 481

Codeforces Round #214 (Div. 2) C: Dima and Salad 想减肥?吃沙拉

#include #include #include using namespace std; struct abc{ int t, a; }c[110]; int dp[2][200000]; int main(){ freopen("in.txt",&q...
  • u012952004
  • u012952004
  • 2013-11-29 01:27
  • 668
    个人资料
    • 访问:207518次
    • 积分:7066
    • 等级:
    • 排名:第3863名
    • 原创:522篇
    • 转载:3篇
    • 译文:0篇
    • 评论:12条
    文章分类
    最新评论