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

最新文章

  1. javascript call与apply关键字的作用
  2. 【BZOJ1984】月下“毛景树” 树链剖分+线段树
  3. [算法导论]DFS @ Python
  4. C/C++的一些备忘
  5. Xcode7.01相对于底版本的变动小结
  6. JLRoutes--处理复杂的URL schemes-备
  7. 安装dnvm
  8. CSS 实现的各种球体效果
  9. HDU 1159 Common Subsequence【dp+最长公共子序列】
  10. 扩展 KMP
  11. java开源安全框架-------Apache Shiro--第一天
  12. python—DAY1
  13. pip 安装第三方包提示Unknown or unsupported command &#39;install&#39;
  14. NN 激活函数 待修改
  15. 一篇自己都看不懂的Matrix tree总结
  16. hdu5157 Harry and magic string【manacher】
  17. leetcode python 001
  18. [Proposal]Transform ur shapes!
  19. CRM项目完成实现
  20. [翻译] PTEHorizontalTableView

热门文章

  1. OSX下安装VMware虚拟机, 加载kali系统
  2. APP测试体系
  3. canvas转图片
  4. Spring的PropertyPlaceholderConfigurer事例应用
  5. Python-统计svn变更代码行数
  6. WCF 客户端 BasicHttpBinding 兼容 HTTPS 和 HTTP
  7. HttpServletRequest对象(一)
  8. C++高性能转换大小写算法
  9. centos nginx+php+mysql 安装libiconv不成功
  10. CentOS7 通过代理上网