CF1666C-Connect the Points

CF1666C-Connect the Points

题目大意

给你平面上的三个点,用垂直于坐标轴的线段连接这三个点,使得线段总长度最小。

题解

考虑 \(x\) 坐标中间的那个点,建立一条覆盖三个点纵坐标的竖直的线段。将两侧的两个点通过水平线段连接到这条线段即可。

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define umap unordered_map
#define endl '\n'
using namespace std;
using i128 = __int128;
const int mod =1e9+7;
template <typename T>void read(T&x){
    x=0;int f = 1;
    char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    x*=f;
}
template <typename T>void print(T x) {
     if (x < 0) { putchar('-'); x = -x; }
     if (x > 9) print(x / 10);
     putchar(x % 10 + '0');
}
#define int long long
const int N=500005;
const int M=2000005;
inline void solve()
{
	pair<int,int> p[3];
	for(int i=0;i<3;i++) cin>>p[i].first>>p[i].second;
	sort(p,p+3);
	cout<<3<<endl;
	cout<<p[1].first<<" "<<min({p[0].second,p[1].second,p[2].second})<<" "<<p[1].first<<" "<<max({p[0].second,p[1].second,p[2].second})<<endl;
	cout<<p[0].first<<" "<<p[0].second<<" "<<p[1].first<<" "<<p[0].second<<endl;
	cout<<p[2].first<<" "<<p[2].second<<" "<<p[1].first<<" "<<p[2].second<<endl;
	
}

signed main()
{
	ios;
	int T=1;
//	cin>>T;
	for(;T--;) solve();
	return 0;
}
posted @ 2025-11-29 13:38  NDAKJin  阅读(6)  评论(0)    收藏  举报