首页 > 其他 > 详细

CodeForces 596A Wilbur and Swimming Pool

时间:2016-05-07 22:01:47      阅读:276      评论:0      收藏:0      [点我收藏+]

水题。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

struct X
{
    int x,y;
}s[5],tmp[5];

int n;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&s[i].x,&s[i].y);

    int flag=-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(s[i].x!=s[j].x&&s[i].y!=s[j].y)
            {
                flag=1;
                tmp[1]=s[i];
                tmp[2]=s[j];
                tmp[3].x=s[i].x; tmp[3].y=s[j].y;
                tmp[4].x=s[j].x; tmp[4].y=s[i].y;
                break;
            }
        }
        if(flag==1) break;
    }
    if(flag==-1) printf("-1\n");
    else
    {
        flag=0;
        for(int i=1;i<=n;i++)
        {
            bool f=0;
            for(int j=1;j<=4;j++)
            {
                if(s[i].x==tmp[j].x&&s[i].y==tmp[j].y) f=1;
            }
            if(f==0) flag=-1;
        }
        if(flag==-1) printf("-1\n");
        else{
            printf("%d\n",abs(tmp[1].x-tmp[2].x)*abs(tmp[1].y-tmp[2].y));
        }
    }

    return 0;
}

 

CodeForces 596A Wilbur and Swimming Pool

原文:http://www.cnblogs.com/zufezzt/p/5469152.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!