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. Java:双向链表反转实现

    有个小需求要求实现一个双向链表的反转于是就有了下边代码: 链表元素结构定义: package com.util; public class LinkedNode<T>{ private T ...

  2. (纪录片)你必须知道的科学 The Science That You Have To Know (2014)

    简介: 类型: 纪录片制片国家/地区: 英国语言: 英语上映日期: 2014-2片长: 150分钟 主要内容: 你有没有认真想过,自己的身体有多奇妙?人体是世间最复杂的一项工程杰作,他也带来了一些非常 ...

  3. SDE操作的许可问题

    ArcGIS二次开发和ArcGIS桌面应用中,许可是一个老生常谈的问题.以前也小结过一些经验.参考: http://www.cnblogs.com/liweis/p/4185311.html 问题描述 ...

  4. Centos7中安装Docker

    1.配置docker镜像安装源 tee /etc/yum.repos.d/docker.repo <<-'EOF' [dockerrepo] name=Docker Repository ...

  5. 如何解析android访问webservice返回的SoapObject数据(可用)

    怎么解析android访问webservice返回的SoapObject数据 本帖最后由 kkDragon123 于 2013-03-26 15:50:07 编辑 我的数据如下:mingdanResp ...

  6. MapReduce任务参数调优(转)

    http://blog.javachen.com/2014/06/24/tuning-in-mapreduce/ 本文主要记录Hadoop 2.x版本中MapReduce参数调优,不涉及Yarn的调优 ...

  7. vue 模板如何解析

    1.模板 一个最简答的模板: <div id="app"> {{ message }} </div> v-for模板: <ul id="ex ...

  8. Java多线程之syncrhoized内置互斥锁的用法详解

       转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/5827547.html    解决并行冲突最有效的方法就是加同步锁,主要有以下几种方法:   1:动态方法 ...

  9. length-of-last-word 最后一个单词的长度

    Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the le ...

  10. 怎样使用Fiddler获取WebApi的token值?

    User-Agent: Fiddler Host: localhost: Content-Length: Content-Type: application/json grant_type=passw ...