CodeForces 596A Wilbur and Swimming Pool

水题。

#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;
}

 

posted @ 2016-05-07 20:49  Fighting_Heart  阅读(140)  评论(0编辑  收藏  举报