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

B. Eight Point Sets的更多相关文章

  1. TSQL 分组集(Grouping Sets)

    分组集(Grouping Sets)是多个分组的并集,用于在一个查询中,按照不同的分组列对集合进行聚合运算,等价于对单个分组使用“union all”,计算多个结果集的并集.使用分组集的聚合查询,返回 ...

  2. grouping sets从属子句的运用

    grouping sets主要是用来合并多个分组的结果. 对于员工目标业绩表'businessTarget': employeeId targetDate idealDistAmount 如果需要分别 ...

  3. Codeforces 722D. Generating Sets

    D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. 【转】rollup、cub、grouping sets、grouping、grouping_id在报表中的应用

    摘自 http://blog.itpub.net/26977915/viewspace-734114/ 在报表语句中经常要使用各种分组汇总,rollup和cube就是常用的分组汇总方式. 第一:gro ...

  5. salesforce 零基础学习(十九)Permission sets 讲解及设置

    Permission sets以及Profile是常见的设置访问权限的方式. Profile规则为'who see what'.通过Profile可以将一类的用户设置相同的访问权限.对于有着相同Pro ...

  6. Python数据类型之“集合(Sets)与映射(Mapping)”

    一.集合类型(Sets) 集合对象是不同的(不可重复)hashable对象的无序集合.常见用法包括:成员关系测试.移除序列中的重复.以及科学计算,例如交集.并集.差分和对称差分.通俗点来说,集合是一个 ...

  7. 【Swift学习】Swift编程之旅---集合类型之Sets(七)

    Sets是存储无序的相同类型的值,你可以在顺序不重要的情况下使用Sets来替代数组,或者当你需要同一个值在集合中只出现一次时. 一.Sets类型语法  写作Set<Element>,Ele ...

  8. Support for multiple result sets

    https://blueprints.launchpad.net/myconnpy/+spec/sp-multi-resultsets Calling a stored procedure can p ...

  9. CF722D. Generating Sets[贪心 STL]

    D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  10. 转:GROUPING SETS、ROLLUP、CUBE

    转:http://blog.csdn.net/shangboerds/article/details/5193211 大家对GROUP BY应该比较熟悉,如果你感觉自己并不完全理解GROUP BY,那 ...

随机推荐

  1. Python3 使用 matplotlib 画折线图

    ChartUtil.py import matplotlib.pyplot as plt from pylab import mpl def plotLine(xData,yData,xLabel,c ...

  2. (转)溶解shader

    游戏中物体腐化消失,燃烧消失时,会有从局部慢慢消失的效果,然后配合一些粒子特效,就能达到非常好的美术效果.类似效果如下: 注:_DissColor为溶解主色,_AddColor为叠加色,按照溶解的移动 ...

  3. ArcEngine应用程序中无法实现TOC图层多选

    在ArcMap的内容列表中,Ctrl和Shift多选.反选等操作图层非常方便. 然而遗憾的是:经测试,查证在ArcEngine应用程序中无法使用此接口,只能通过在Desktop中来使用IContent ...

  4. http支付导图流程

    第三方提交数据到官方的URL(加带参数)---官方服务器处理完成---跳转到第三方URL(加带参数)---第三处理---结束

  5. iOS webservice SOAP 请求

    1. Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的.专门的第三方软件或硬件, 就可相互交换数据或集成.依据Web Service规范实施的应用之间, 无论它们所使用的语 ...

  6. 微信小程序 - 图片懒加载

    wxml <!-- 数据源 --> <view class='item-{{index}}' wx:for="{{lazyData}}" wx:key=" ...

  7. JAVA设计模式——第 8 章 适配器模式【Adapter Pattern】(转)

    好,请安静,后排聊天的同学别吵醒前排睡觉的同学了,大家要相互理解嘛.今天讲适配器模式,这个模式也很简单,你笔记本上的那个拖在外面的黑盒子就是个适配器,一般你在中国能用,在日本也能用,虽然两个国家的的电 ...

  8. Audition CC2019 MME设备内部错误怎么解决!

    安装完了AA2019,没有想到像昨天安装系统那么不顺利... 当然出现问题的原因是因为我安装了win10 并且我禁用了麦克风的所有应用权限. 设置里面搜索 麦克风 权限 Ok工作啦, 好开森~     ...

  9. AOP技术分析

    AOP的概述(http://www.cnblogs.com/lxp503238/p/6837653.html)        1. 什么是AOP的技术?        * 在软件业,AOP为Aspec ...

  10. js instanceof 实现原理

    function instanceof(left, right) { // 获得类型的原型 let prototype = right.prototype // 获得对象的原型 left = left ...