CodeForces - 334B Eight Point Sets(模拟)

Description:

现在给定8个点,问能否找到三个整数x1, x2, x3 和另外三个整数 y1, y2, y3,满足 x1 < x2 < x3, y1 < y2 < y3,使得 (xi, yj) (1 ≤ i, j ≤ 3)这9个点除去(x2, y2)点后的8个点恰好为给定的8个点。

给出这个8个点,请你确定是否能找到这些整数。

Input

输入有8行,第 i 行包含两个整数,xi 和 yi (0 ≤ xi, yi ≤ 106)。

Output

一行,一个单词,如果能找出6个满足条件的数,输出 "respectable" 否则输出 "ugly" 。

Example

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

题意很简单,就是基本的模拟,但是需要注意的条件的很多,我错了好几次才发现

AC代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
typedef double ld;
const int INF = 0x3f3f3f3f;
const int N=1000010;
int i,j,k;
int m;
int res,ans,cnt,temp;

struct Node
{
    int x,y;
    int id;
} n[9];
int ck[3]={1,4,6};
int ck2[3]={3,5,8};
bool cmp(Node a,Node b)
{
    if(a.x != b.x)
        return a.x < b.x;
    else
    return a.y<b.y;
}
int main()
{
    for(i=1;i<=8;i++)
    {
        scanf("%d %d",&n[i].x,&n[i].y);
    }
    sort(n+1,n+8+1,cmp);
    int flag=1 ;
    for(i=1;i<3;i++)
    {
        if(n[i].x!=n[i+1].x)
            flag=0;
        if(n[i].y==n[i+1].y)
            flag=0;
    }
    if(n[4].x!=n[5].x)
        flag=0;
    for(i=6;i<8;i++)
    {
        if(n[i].x!=n[i+1].x)
            flag=0;
    }
    for(k=0; k<2; k++)
    {
        if(n[ck[k]].y!=n[ck[k+1]].y)
            flag=0;
        if(n[ck[k]].x==n[ck[k+1]].x)
            flag=0;
    }
    if(n[2].y!=n[7].y)
        flag=0;
    for(k=0;k<2;k++)
    {
        if(n[ck2[k]].y!=n[ck2[k+1]].y)
            flag=0;
    }
    if(flag)
         printf("respectable\n");
    else
         printf("ugly\n");
    return 0 ;
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值