B. Eight Point Sets

B. Eight Point Sets
 
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).

You have a set of eight points. Find out if Gerald can use this set?

Input

The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.

Output

In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.

Sample test(s)
input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
output
respectable
input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
output
ugly
input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
output
ugly

 

刚开始没看懂意思,其实就是,给你满足x1<x2<x3, y1<y2<y3, 然后用这六个数组成九个点,去掉(x2,y2)点,剩下的八个点是否满足条件:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

struct node{
    int x,y;
}p[8];

int a[10],b[10];

int cmp(node a,node b){
    if(a.x==b.x)
        return a.y<b.y;
    return a.x<b.x;
}

int main() {

    //freopen("input.txt","r",stdin);

    while(~scanf("%d%d",&p[0].x,&p[0].y)){
        a[0]=p[0].x,    b[0]=p[0].y;
        int cnt1=1,cnt2=1;
        for(int i=1;i<8;i++){
            scanf("%d%d",&p[i].x,&p[i].y);
            int flag1=1,flag2=1;
            for(int j=0;j<cnt1;j++)
                if(p[i].x==a[j])
                    flag1=0;
            if(flag1)
                a[cnt1++]=p[i].x;
            for(int j=0;j<cnt2;j++)
                if(p[i].y==b[j])
                    flag2=0;
            if(flag2)
                b[cnt2++]=p[i].y;
        }
        if(cnt1!=3 || cnt2!=3){     //判断点x==3?  点y==3?
            puts("ugly");
            continue;
        }
        sort(a,a+3);
        sort(b,b+3);
        if(a[0]==a[1] || a[1]==a[2] || b[0]==b[1] || b[1]==b[2]){   //是否满足x1<x2<x3  且  y1<y2<y3
            puts("ugly");
            continue;
        }
        sort(p,p+8,cmp);
        int flag=1,cnt=0;
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++){   //和输出对拍,看看是否相同
                if(i==1 && j==1)    //去掉点(x2,y2)
                    continue;
                if(a[i]==p[cnt].x && b[j]==p[cnt].y)
                    cnt++;
                else{
                    flag=0;
                    break;
                }
            }
        if(flag)
            puts("respectable");
        else
            puts("ugly");
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值