Codeforces Round #340 (Div. 2) D

Description

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 -1
1 1
1 2
output
1
input
-1 -1
-1 3
4 3
output
2
input
1 1
2 3
3 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:

没什么好说的,注意情况就是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int main()
{
    int x1,y1,x2,y2,x3,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    if(x1==x2&&x2==x3||y1==y2&&y2==y3)
    {
        cout<<1;
    }
    else if(x1==x2&&y3<=min(y1,y2)||x1==x2&&y3>=max(y1,y2))
    {
        cout<<2;
    }
    else if(y1==y2&&x3<=min(x1,x2)||y1==y2&&x3>=max(x1,x2))
    {
        cout<<2;
    }
    else if(x1==x3&&y2<=min(y1,y3)||x1==x3&&y2>=max(y1,y3))
    {
        cout<<2;
    }
    else if(y1==y3&&x2<=min(x1,x3)||y1==y3&&x2>=max(x1,x3))
    {
        cout<<2;
    }
    else if(x2==x3&&y1<=min(y2,y3)||x2==x3&&y1>=max(y2,y3))
    {
        cout<<2;
    }
    else if(y2==y3&&x1<=min(x2,x3)||y2==y3&&x1>=max(x2,x3))
    {
        cout<<2;
    }
    else
    {
        cout<<3;
    }
    return 0;
}

  

posted @   樱花落舞  阅读(277)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示