Codeforces Round #340 (Div. 2) D. Polyline

<div>
</div>
D. Polyline
time limit per test
memory limit per test
input
output
Input
Output standard outputstandard input256 megabytes1 second

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.

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:




題意:求連接3個點最少需要幾條平行於座標軸的線段
枚舉所有情況即可


#include 
#include 
#include 
#include 
#include 
using namespace std;

vector >v;

int main()
{
   int x1,x2,x3,y1,y2,y3;
   cin>>x1>>y1>>x2>>y2>>x3>>y3;
   v.push_back(make_pair(x1,y1));
   v.push_back(make_pair(x2,y2));
   v.push_back(make_pair(x3,y3));
   sort(v.begin(),v.end());
   /*for(int i=0;i<3;i++){
      cout<=v[1].second||v[2].second<=v[0].second)||xx2==0&&(v[0].second>=v[2].second||v[0].second<=v[1].second))
         f=2;
         if(yy1==0||yy2==0)
            f=2;
         if(f==0){
            f=3;
         }
   }
   cout<

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章