B. Eight Point Sets
1 second
256 megabytes
standard input
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?
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.
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
respectable
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
ugly
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
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的更多相关文章
- TSQL 分组集(Grouping Sets)
分组集(Grouping Sets)是多个分组的并集,用于在一个查询中,按照不同的分组列对集合进行聚合运算,等价于对单个分组使用“union all”,计算多个结果集的并集.使用分组集的聚合查询,返回 ...
- grouping sets从属子句的运用
grouping sets主要是用来合并多个分组的结果. 对于员工目标业绩表'businessTarget': employeeId targetDate idealDistAmount 如果需要分别 ...
- Codeforces 722D. Generating Sets
D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 【转】rollup、cub、grouping sets、grouping、grouping_id在报表中的应用
摘自 http://blog.itpub.net/26977915/viewspace-734114/ 在报表语句中经常要使用各种分组汇总,rollup和cube就是常用的分组汇总方式. 第一:gro ...
- salesforce 零基础学习(十九)Permission sets 讲解及设置
Permission sets以及Profile是常见的设置访问权限的方式. Profile规则为'who see what'.通过Profile可以将一类的用户设置相同的访问权限.对于有着相同Pro ...
- Python数据类型之“集合(Sets)与映射(Mapping)”
一.集合类型(Sets) 集合对象是不同的(不可重复)hashable对象的无序集合.常见用法包括:成员关系测试.移除序列中的重复.以及科学计算,例如交集.并集.差分和对称差分.通俗点来说,集合是一个 ...
- 【Swift学习】Swift编程之旅---集合类型之Sets(七)
Sets是存储无序的相同类型的值,你可以在顺序不重要的情况下使用Sets来替代数组,或者当你需要同一个值在集合中只出现一次时. 一.Sets类型语法 写作Set<Element>,Ele ...
- Support for multiple result sets
https://blueprints.launchpad.net/myconnpy/+spec/sp-multi-resultsets Calling a stored procedure can p ...
- CF722D. Generating Sets[贪心 STL]
D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 转:GROUPING SETS、ROLLUP、CUBE
转:http://blog.csdn.net/shangboerds/article/details/5193211 大家对GROUP BY应该比较熟悉,如果你感觉自己并不完全理解GROUP BY,那 ...
随机推荐
- 云服务器 ECS Linux Ubuntu 主机修改主机名
云服务器 ECS Linux 主机修改主机名 修改云服务器 ECS Linux 主机名常见的有两种方式,本文对此进行概要说明. 临时生效修改 使用命令行修改 hostname 主机名(可自定义),重新 ...
- USACO Arithmetic Progressions(暴力)
题目请点我 题解: 这道题的题意是找出集合里全部固定长度为N的等差数列.集合内的元素均为P^2+q^2的形式(0<=p,q<=M).时间要求5s内.本着KISS,直接暴力. 可是后来竟超时 ...
- ecshop二次开发 使用ecshop电子商务系统的100个小问题
自己从事B4C电子商务开发一段时间了,特别对ecshop深有体会,刚接触的时候不容易理解,下面将根据自己的经验,来总结100条关于操作ecshop电子商务系统的小问题. 1:如何修改网站"欢 ...
- uni-app - 支付(app支付、小程序支付、h5(微信端)支付)
App支付.小程序支付.h5(微信端)支付 APP支付(内置) appPay.js /** * 5+App支付,仅支持支付宝以及微信支付 * * 支付宝Sdk集成,微信sdk未集成 * * @para ...
- thick置备和 thin置备,克隆,模板和快照
共享shared VMDK和共享RDM实验,参见http://wenku.it168.com/d_000773128.shtml 假如你有一个磁盘是100G的虚拟机,磁盘格式是厚置备,即Thick,当 ...
- websocket与canvas[转]
server端还是用tomcat7的方式客户端 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ...
- linux2.6.30.4内核移植(5)——构建根文件系统(yaffs文件系统格式的镜像)
一.首先编译并安装BusyBox 这里使用的交叉编译器还是3.4.5. 注意:编译内核.编译BusyBox以及编译文件系统中的所有应用程序的交叉编译器要使用同一个版本. 1.获取BusyBox源码 下 ...
- 【Python】文件读写操作
Python的文件读写有点类似php的文件读写.php的文件读写已经在<[php]让记事本成为你调控变量的控制台>(点击打开链接)说过了,以下用一个小样例说明Python的文件读写. 在F ...
- SqlDataAdapter概述
SqlDataAdapter是 DataSet和 SQL Server之间的桥接器,用于检索和保存数据.SqlDataAdapter通过对数据源使用适当的Transact-SQL语句映射 Fill(它 ...
- J4架构应用过程中出现的问题与解决摘录
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6369346.html sendRedirect()的页面不能用EL表达式获取参数:因为是新的request.E ...