codeforces 334B. Eight Point Sets

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define ls rt<<1
#define rs ls1
#define lson l,mid,ls
#define rson mid+1,r,rs
#define middle (l+r)>>1
#define eps (1e-9)
#define clr_all(x,c) memset(x,c,sizeof(x))
#define clr(x,c,n) memset(x,c,sizeof(x[0])*(n+1))
#define MOD 1000000007
#define inf 100000007
#define pi acos(-1.0)
#define M 200000+5
struct type{
int x,y;
}p[10];
type a[3][3];
int sum1,sum2;
bool cmp(type a,type b){
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
int check(){
if(a[0][0].x!=a[0][1].x||a[0][1].x!=a[0][2].x||a[0][0].x!=a[0][2].x)
return 1;
if(a[1][0].x!=a[1][2].x)
return 1;
if(a[2][0].x!=a[2][1].x||a[2][1].x!=a[2][2].x||a[2][0].x!=a[2][2].x)
return 1;

if(a[0][0].y!=a[1][0].y||a[1][0].y!=a[2][0].y||a[0][0].y!=a[2][0].y)
return 1;
if(a[0][1].y!=a[2][1].y)
return 1;
if(a[0][2].y!=a[1][2].y||a[1][2].y!=a[2][2].y||a[0][2].y!=a[2][2].y)
return 1;

if(a[0][0].y>=a[0][1].y||a[0][0].y>=a[0][2].y||a[0][1].y>=a[0][2].y)
return 1;
if(a[1][0].y>=a[1][2].y)
return 1;
if(a[2][0].y>=a[2][1].y||a[2][0].y>=a[2][2].y||a[2][1].y>=a[2][2].y)
return 1;

if(a[0][0].x>=a[1][0].x||a[0][0].x>=a[2][0].x||a[1][0].x>=a[2][0].x)
return 1;
if(a[0][1].x>=a[2][1].x)
return 1;
if(a[0][2].x>=a[1][2].x||a[0][2].x>=a[2][2].x||a[1][2].x>=a[2][2].x)
return 1;
return 0;
}
int main(){
    int flag=0,i,j,k=1;
    sum1=0,sum2=0;
    for(i=1;i<=8;i++){
scanf("%d %d",&p[i].x,&p[i].y);
sum1+=p[i].x;
sum2+=p[i].y;
}
sort(p+1,p+9,cmp);
for(i=0;i<3;i++){
a[0][i].x=p[k].x;
a[0][i].y=p[k].y;
k++;
}
a[1][0].x=p[k].x;a[1][0].y=p[k++].y;
a[1][2].x=p[k].x;a[1][2].y=p[k++].y;
for(i=0;i<3;i++){
a[2][i].x=p[k].x;
a[2][i].y=p[k].y;
k++;
}
if(check()==0)puts("respectable");
else puts("ugly");
//for(i=1;i<=8;i++)printf("%d %d\n",p[i].x,p[i].y);
//system("pause");
    return 0;
}

你可能感兴趣的:(codeforces)