Codeforces Round #340 (Div. 2) D
1 second
256 megabytes
standard input
standard output
There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of.
Each of the three lines of the input contains two integers. The i-th line contains integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th point. It is guaranteed that all points are distinct.
Print a single number — the minimum possible number of segments of the polyline.
1 -1
1 1
1 2
1
-1 -1
-1 3
4 3
2
1 1
2 3
3 2
3
The variant of the polyline in the first sample:

The variant of the polyline in the second sample:

The variant of the polyline in the third sample:

题意 三个点 划平行于坐标轴的线 没有自生相交
问有多少个线段组成
特别样例
0 0
0 1
1 2
这把 hack 了别人几发 代码写搓了 现在补
#include<iostream>
#include<cstdio>
using namespace std;
__int64 x1,y1,x2,y2,x3,y3;
int main()
{
scanf("%I64d %I64d %I64d %I64d %I64d %I64d",&x1,&y1,&x2,&y2,&x3,&y3);
if((x1==x2&&x2==x3)||(y1==y2&&y2==y3))
printf("1\n");
else
{
if((x2==x3&&y3>y2&&(y1>=y3||y1<=y2))||(x2==x3&&y2>y3&&(y1>=y2||y1<=y3))|| (x1==x2&&y1>y2&&(y3>=y1||y3<=y2))||(x1==x2&&y1<y2&&(y3>=y2||y3<=y1))||(x1==x3&&y1>y3&&(y2>=y1||y2<=y3))||(x1==x3&&y1<y3&&(y2>=y3||y2<=y1))|| (y1==y2&&x1<x2&&(x3<=x1||x3>=x2))||(y1==y2&&x1>x2&&(x3>=x1||x3<=x2))||(y2==y3&&x3>x2&&(x1>=x3||x1<=x2))||(y2==y3&&x2>x3&&(x1>=x2||x1<=x3))|| (y1==y3&&x1<x3&&(x2<=x1||x2>=x3))||(y1==y3&&x1>x3&&(x2>=x1||x2<=x3)))
printf("2\n");
else
printf("3\n");
}
return 0;
}
Codeforces Round #340 (Div. 2) D的更多相关文章
- [Codeforces Round #340 (Div. 2)]
[Codeforces Round #340 (Div. 2)] vp了一场cf..(打不了深夜的场啊!!) A.Elephant 水题,直接贪心,能用5步走5步. B.Chocolate 乘法原理计 ...
- Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 莫队算法
E. XOR and Favorite Number 题目连接: http://www.codeforces.com/contest/617/problem/E Descriptionww.co Bo ...
- Codeforces Round #340 (Div. 2) C. Watering Flowers 暴力
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerb ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
- 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)
题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...
- Codeforces Round #340 (Div. 2) E. XOR and Favorite Number 【莫队算法 + 异或和前缀和的巧妙】
任意门:http://codeforces.com/problemset/problem/617/E E. XOR and Favorite Number time limit per test 4 ...
- Codeforces Round #340 (Div. 2) E. XOR and Favorite Number —— 莫队算法
题目链接:http://codeforces.com/problemset/problem/617/E E. XOR and Favorite Number time limit per test 4 ...
- Codeforces Round #340 (Div. 2) E. XOR and Favorite Number (莫队)
题目链接:http://codeforces.com/contest/617/problem/E 题目大意:有n个数和m次查询,每次查询区间[l, r]问满足ai ^ ai+1 ^ ... ^ aj ...
随机推荐
- 前端开发工程师 - 02.JavaScript程序设计 - 第2章.进阶篇
第2章--进阶篇 类型进阶 类型: Undefined Null Boolean String Number Object 原始类型(值类型):undefined, null, true, " ...
- lintcode12 带最小值操作的栈
实现一个带有取最小值min方法的栈,min方法将返回当前栈中的最小值. 你实现的栈将支持push,pop 和 min 操作,所有操作要求都在O(1)时间内完成. 建一个栈helpStack,用来存放从 ...
- [Clr via C#读书笔记]Cp8方法
Cp8方法 构造器 作用就是初始化所有成员字段:.ctor:派生类和基类都有自己的构造函数.默认有一个无参数的构造函数,值字段初始化为0,引用字段初始化为null:可以有多个构造器: 值类型的初始化其 ...
- 上楼梯问题(递归C++)
[问题描述] 小明上楼梯,一次可以迈1步,2步和3步,假设楼梯共有n个台阶,输出他所有的走法. [代码展示] #include<iostream>using namespace std;i ...
- Balanced Lineup:线段树:区间最值 / RMQ
不要被线段树这个名字和其长长的代码吓到. D - Balanced Lineup Description For the daily milking, Farmer John's N cows (1 ...
- Python实现个性化推荐一
现如今,网站用推荐系统为你提供个性化的体验,告诉你买啥,吃啥甚至你应该和谁交朋友.尽管每个人口味不同,但大体都适用这个套路.人们倾向于喜欢那些与自己喜欢的其他东西相似的东西,也倾向于与自己身边的人有相 ...
- 为什么23种设计模式中没有MVC
GoF (Gang of Four,四人组, <Design Patterns: Elements of Reusable Object-Oriented Software>/<设计 ...
- Spring管理事务默认回滚的异常
一.默认方式 Spring的事务管理默认只对出现运行期异常(java.lang.RuntimeException及其子类),Error进行回滚. 如果一个方法抛出Exception或者Checked异 ...
- lintcode-179-更新二进制位
179-更新二进制位 给出两个32位的整数N和M,以及两个二进制位的位置i和j.写一个方法来使得N中的第i到j位等于M(M会是N中从第i为开始到第j位的子串) 注意事项 In the function ...
- TCP系列10—连接管理—9、syncookie、fastopen与backlog
这部分内容涉及较多linux实现,可以跳过. 一.listen系统调用对backlog的处理 当socket处于LISTEN或者CLOSED状态时,fastopen队列的长度可以通过TCP_FASTO ...