codeforces B. Eight Point Sets 解题报告
题目链接:http://codeforces.com/problemset/problem/334/B
一开始看到题目,有点怯,理解了题目后,其实并不难。这句话是突破口 three distinct integer vertical straight lines and three distinct integer horizontal straight lines(三个不同的整数所组成的垂直直线和三个不同的整数所组成的水平直线)。
首先要保证三个x是不同的(x1 != x2 != x3),三个y当然也是。x1包括三个相同的点(x11 = x12 = x13),x2包括两个相同的点(x21 = x22),x3包括三个相同的点(x31 = x32 = x33);y1的三个点则保证不同(y11 != y12 != y13),y2的两个点保证不同(y21 != y22),y3的三个点不同(y31 != y32 != y33)。然后要保证y11 = y21 = y31,y12 = y32,y13 = y22,y13 = y22 = y33,注意,不是y12 = y22 = y32,这是很容易错的)。另外,排序函数的cmp的运用起到了预处理的作用。
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
using namespace std; struct set
{
int x, y;
}p[]; int cmp(set a, set b)
{
if (a.x != b.x) // x不同时(组外)按x(组外)升序排序
return a.x < b.x;
return a.y < b.y; // x相同时(组内)按y(组内)升序排序
} int main()
{
int i;
for (i = ; i < ; i++)
scanf("%d%d", &p[i].x, &p[i].y);
sort(p, p+, cmp);
if (p[].x == p[].x && p[].x == p[].x && p[].x == p[].x &&
p[].x != p[].x && p[].x != p[].x &&
p[].y == p[].y && p[].y == p[].y && p[].y == p[].y &&
p[].y == p[].y && p[].y == p[].y && p[].y != p[].y &&
p[].y != p[].y)
printf("respectable\n");
else
printf("ugly\n");
return ;
}
codeforces B. Eight Point Sets 解题报告的更多相关文章
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces 476C.Dreamoon and Sums 解题报告
题目链接:http://codeforces.com/problemset/problem/476/C 题目意思:给出两个数:a 和 b,要求算出 (x/b) / (x%b) == k,其中 k 的取 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- codeforces 507B. Amr and Pins 解题报告
题目链接:http://codeforces.com/problemset/problem/507/B 题目意思:给出圆的半径,以及圆心坐标和最终圆心要到达的坐标位置.问最少步数是多少.移动见下图.( ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces B. Xenia and Ringroad 解题报告
题目链接:http://codeforces.com/problemset/problem/339/B 题目理解不难,这句是解题的关键 In order to complete the i-th ta ...
- codeforces 462C Appleman and Toastman 解题报告
题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得 ...
- codeforces 460A Vasya and Socks 解题报告
题目链接:http://codeforces.com/problemset/problem/460/A 题目意思:有一个人有 n 对袜子,每天早上会穿一对,然后当天的晚上就会扔掉,不过他会在 m 的倍 ...
- codeforces 567D.One-Dimensional Battle Ships 解题报告
题目链接:http://codeforces.com/problemset/problem/567/D 题目意思:给出 1 * n 的 field,编号从左至右依次为 1,2,...,n.问射 m 枪 ...
随机推荐
- 【Gym 100733D】Little thief Shi
题 Shi realized that he was almost out of money, even renting Shitalian lands. Shi was walking on a s ...
- 4.Android下拉列表框spinner学习
下拉列表框被广泛使用,诸如淘宝.京东等手机端经常可以看到这个部件身影,今天就来学习下它. 首先布局文件增加代码:如图 接下来在values下增加arrays.xml 如图 ...
- [NOIP2010] 提高组 洛谷P1540 机器翻译
题目背景 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 题目描述 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件会先 ...
- newinstance和new有什么区别
用newInstance与用new是区别的,区别在于创建对象的方式不一样,前者是使用类加载机制,那么为什么会有两种创建对象方式?这个就要从可伸缩.可扩展,可重用等软件思想上解释了.Java中工厂模式经 ...
- std::shared_ptr(二)
Defined in header <memory> template< class T > class shared_ptr; (since C++11) ...
- 删除ecshop底部共执行个查询Gzip 已禁用,占用内存方法
删除ecshop底部共执行个查询Gzip 已禁用,占用内存方法 ECSHOP教程/ ecshop教程网(www.ecshop119.com) 2013-03-25 “共执行 41 个查询,用时 2 ...
- JDBCTemplate基础学习
JDBCTemplate:spring提供的用于操作数据库的模板,类似DbUtils.使用时必须设置数据源(DataSource):数据源如DBCP.C3P0等 一.JDBCAPI简单使用Demo 1 ...
- HTML 5 应用程序缓存
使用 HTML5,通过创建 cache manifest 文件,可以轻松地创建 web 应用的离线版本. 什么是应用程序缓存(Application Cache)? HTML5 引入了应用程序缓存,这 ...
- 通过telnet连接查看memcache服务器(转)
memcache作为一款优秀的进程外缓存,常常被运用于高并发系统架构中.这里主要谈谈怎么通过telnet工具,查看memcache运行状况并对其key进行管理维护.假设memcache安装目录:/us ...
- 10 steps to becoming the developer everyone wants
You thought it was all about programming skills. But you were wrong! Great code is fine, yet command ...