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 ...
随机推荐
- Python常用函数--return 语句
在Python教程中return 语句是函数中常用的一个语句.return 语句用于从函数中返回,也就是中断函数.我们也可以选择在中断函数时从函数中返回一个值.案例(保存为 function_retu ...
- 关于java获取网页内容
最近项目需求,做一些新闻站点的爬取工作.1.简单的jsoup爬取,静态页面形式: String url="a.atimo.cn";//静态页面链接地址Document doc = ...
- ionic 组件学习
利用css列表多选框: <div class="{{Conceal}}" > <ion-checkbox color="secondary" ...
- Matlab提速方法
1. 向量化. 尽量少用for循环. 2. 循环竖着走比横着走快. 3. 内置函数也有优化的空间 不少内置函数都有大量的error check.直接用profiler找出真正干活的.不少内置函数在网上 ...
- 一:HDFS 用户指导
1.hdfs的牛逼特性 Hadoop, including HDFS, is well suited for distributed storage and distributed processin ...
- this指针与const成员函数
this指针的类型为:classType *const // 即指向类类型非常量版本的常量指针 所以,我们不能把this绑定到一个常量对象上 ===> 不能在一个常量对象上调用普通的 ...
- javaIO--字符流
java提供字符流对自否刘式文件进行数据读写操作.字符输入流类是Reader及其子类,输出流是Writer及其子类. 另外,上一篇javaIO写的是字节流,字节流方式也可以对以字符为基本类型的流式文件 ...
- 项目uml
[团队信息] 团队项目: 小葵日记--主打记录与分享模式的日记app 队名:日不落战队 队员信息及贡献分比例: 短学号 名 本次作业博客链接 此次作业任务 贡献分配 备注 501 安琪 http:// ...
- TCP系列20—重传—10、早期重传(ER)
一.介绍 在前面介绍thin stream时候我们介绍过有两种场景下可能不会产生足够的dup ACK来触发快速重传,一种是游戏类响应交互式tcp传输,另外一种是传输受到拥塞控制的限制,只能发送少量TC ...
- zookeeper伪集群安装
记录下zookeeper伪分布式搭建的过程,假设系统已经配置好了JAVA环境. 1.准备环境 linux服务器一台,下载某个版本的zookeeper压缩包,下载链接:http://apache.cla ...