Codeforces D Polyline

来源:互联网 发布:史丹利快报的淘宝店 编辑:程序博客网 时间:2024/03/29 18:03

D. Polyline
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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.

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 test(s)
input
1 -11 11 2
output
1
input
-1 -1-1 34 3
output
2
input
1 12 33 2
output
3
Note

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:

恩,开始以为有4的情况呢,后来仔细想了一下是木有的。


#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<stack>#include<queue>using namespace std;struct Node{    int x,y;};Node node[3];bool cmp(Node a,Node b){    if(a.x!=b.x)        return a.x<b.x;    return a.y<b.y;}int main(){    int x1,y1,x2,y2,x3,y3;    while(~scanf("%d%d%d%d%d%d",&node[0].x,&node[0].y,&node[1].x,&node[1].y,&node[2].x,&node[2].y))    {        int sum;        //sort(node,node+3,cmp);        x1=node[0].x;        y1=node[0].y;        x2=node[1].x;        y2=node[1].y;        x3=node[2].x;        y3=node[2].y;        if((x1==x2&&x2==x3)||(y1==y2&&y2==y3))            sum=1;        else if(x1==x2&&(y3>=max(y1,y2)||y3<=min(y1,y2)))            sum=2;        else if(x2==x3&&(y1>=max(y2,y3)||y1<=min(y2,y3)))            sum=2;        else if(x1==x3&&(y2>=max(y1,y3)||y2<=min(y1,y3)))            sum=2;        else if(y1==y2&&(x3>=max(x1,x2)||x3<=min(x1,x2)))            sum=2;        else if(y2==y3&&(x1>=max(x2,x3)||x1<=min(x2,x3)))            sum=2;        else if(y1==y3&&(x2>=max(x1,x3)||x2<=min(x1,x3)))            sum=2;        else            sum=3;        //printf("x1=%d y1=%d x2=%d y2=%d x3=%d y3=%d\n",x1,y1,x2,y2,x3,y3);        /*if((x1==x2&&x2==x3)||(y1==y2&&y2==y3))            sum=1;        else if(x1==x2&&(y3>=max(y1,y2)||y3<=min(y1,y2)))            sum=2;        else if(x2==x3&&(y1>=max(y2,y3)||y1<=min(y2,y3)))            sum=2;        else if(y1==y2&&(x3>=max(x1,x2)||x3<=min(x1,x2)))            sum=2;        else if(y2==y3&&(x1>=max(x2,x3)||x1<=min(x2,x3)))            sum=2;        else if(y1==y3&&(x2>=max(x1,x3)||x2<=min(x1,x3)))            sum=2;        else            sum=3;*/        printf("%d\n",sum);    }    return 0;}


0 0