7.11_SUPER STUPID CROSS

这道题目可以对前1000个进行排序,然后找出最大的横边和竖边,从头开始搜索,一旦找到匹配的就停止搜索输出,而一旦搜到尾,还没有找到匹配的,就输出那句话“ Human intelligence is really terrible ”。

#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

​

int n,an,bn,ans;

struct hen{

    int x;

    int y1,y2;

}h[100010];

struct shu{

    int y;

    int x1,x2;

}s[100010];

​

bool cmph(hen a,hen b){

    return a.y2-a.y1>b.y2-b.y1;

}

bool cmps(shu a,shu b){

    return a.x2-a.x1>b.x2-b.x1;

}

​

int main(){

    cin>>n;

    int i,j,k,xx1,yy1,xx2,yy2;

    for(i=0;i<n;i++){

        scanf("%d%d%d%d",&xx1,&yy1,&xx2,&yy2);

        if(xx1==xx2){h[an].x=xx1;h[an].y1=min(yy1,yy2);h[an].y2=max(yy1,yy2);an++;}

        else{s[bn].y=yy1;s[bn].x1=min(xx1,xx2);s[bn].x2=max(xx1,xx2);bn++;}}

    sort(h,h+an,cmph);sort(s,s+bn,cmps);

    for(i=0;i<min(an,1000);i++)

        for(j=0;j<min(bn,1000);j++){

            if(s[j].x2-s[j].x1<=ans*2||h[i].y2-h[i].y1<=ans*2)continue;

            int r=min(min(s[j].x2-h[i].x,h[i].x-s[j].x1),min(h[i].y2-s[j].y,s[j].y-h[i].y1));

            if(ans<r)

                ans=r;

        }

    if(ans)

        cout<<ans<<endl;

    else

        cout<<"Human intelligence is really terrible"<<endl;

    return 0;

}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值