D. Polyline

题目连接:

http://www.codeforces.com/contest/617/problem/D

Descriptionww.co

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.

Input

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.

Output

Print a single number — the minimum possible number of segments of the polyline.

Sample Input

-1 -1

-1 3

4 3

Sample Output

2

Hint

题意

给你3个点,然后问你能够用多少条平行于坐标轴的线段来穿过这三个点

这些线段是连接在一起的,并且只能在端点处相交

题解:

显然答案只会有1 2 3 这三种

答案为1的,就是这三个点某一维是一样的

答案为2的,就是这三个点有两个点的某一维是相同的,而另外一个点的另外一维是在这个点之外(画个图就懂了

剩下的就是答案为3的

数据:

1 1

1 3

0 2

代码

#include<bits/stdc++.h>
using namespace std; pair<int,int> P[3];
int check(int x,int y,int z)
{
if(x==y)return 0;
if(y==z)return 0;
if(x==z)return 0; if(P[x].first==P[y].first)
{
if(P[x].second<P[y].second)
{
if(P[z].second<=P[x].second||P[z].second>=P[y].second)
return 1;
}
} if(P[x].second==P[y].second)
{
if(P[x].first<P[y].first)
{
if(P[z].first<=P[x].first||P[z].first>=P[y].first)
return 1;
}
} return 0;
}
int main()
{
for(int i=0;i<3;i++)
cin>>P[i].first>>P[i].second; if(P[0].first == P[1].first && P[1].first == P[2].first)
return puts("1");
if(P[0].second == P[1].second && P[1].second == P[2].second)
return puts("1"); for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
for(int k=0;k<3;k++)
if(check(i,j,k))
return puts("2"); return puts("3");
}

Codeforces Round #340 (Div. 2) D. Polyline 水题的更多相关文章

  1. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  2. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  3. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  4. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  5. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  6. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  7. Codeforces Round #338 (Div. 2) A. Bulbs 水题

    A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...

  8. Codeforces Round #282 (Div. 1) A. Treasure 水题

    A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...

  9. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

随机推荐

  1. 工具栏ToolStrip能触发焦点控件的Leave、Validating、DataError等事件以验证数据 z

    public class ToolStripEx : ToolStrip { protected override void OnClick(EventArgs e) { base.OnClick(e ...

  2. LR录制测试脚本

    1.录制的业务流程 2.录制脚本 3.查看脚本

  3. VC++中内存对齐

    我们经常看到求 sizeof(A) 的值的问题,其中A是一个结构体,类,或者联合体. 为了优化CPU访问和优化内存,减少内存碎片,编译器对内存对齐制定了一些规则.但是,不同的编译器可能有不同的实现,本 ...

  4. 在VMware虚拟机中安装CentOS 7

    [声明] 欢迎转载,但请保留文章原始出处 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3917 ...

  5. 开源堡垒机GateOne的安装、配置笔记

    因为内部临时需要这么一套系统,所以搜搜查查,搞定了系统部署,使用pam认证的配置. 系统初始化是使用CentOS 6.5 Mini x64版本.   首先exports http_proxy和http ...

  6. css3.0新属性效果在ie下的解决方案(兼容性)

    css3.0增加的新属性,如投影.渐变.旋转.圆角等等!这些新标准属性在ie6.ie7.ie8浏览器版本里得不到很好的支持,相信ie以后的新版本也会支持这些新属性的.目前ie6.ie7.ie8浏览器不 ...

  7. 运算符重载 C++ 编程思想

    class Integer{ int i; public: Integer(int ii) : i(ii) {} const Integer operator+(const Integer& ...

  8. 【转】asp.net发布到IIS中出现错误:处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”

    原文:http://blog.csdn.net/mazhaojuan/article/details/7660657 开发web项目时需要安装IIS,在安装好IIS的Windows7本上发布asp.n ...

  9. Python超级程序员使用的开发工具

    我以个人的身份采访了几个顶尖的Python程序员,问了他们以下5个简单的问题: 当前你的主要开发任务是什么? 你在项目中使用的电脑是怎样的? 你使用什么IDE开发? 你将来的计划是什么? 有什么给Py ...

  10. 说说Python 中的文件操作 和 目录操作

    我们知道,文件名.目录名和链接名都是用一个字符串作为其标识符的,但是给我们一个标识符,我们该如何确定它所指的到底是常规文件文件名.目录名还是链接名呢?这时,我们可以使用os.path模块提供的isfi ...