题目保证一定存在一条直线 假设这条直线不经过任何线段的端点
那么通过旋转或者平移 一定可以使得线段经过端点
那么只要固定一个端点 再判断斜率范围就好了
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) x&(-x)
#define ll long long
const int maxn=1e4+5;
int n;
struct node{
double xx,h1,h2;
}a[maxn];
double ansx1,ansy1,ansx2,ansy2;
int main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i].xx>>a[i].h1>>a[i].h2;
for(int id=1;id<=n;id++){
double minn=-1e10;
double maxx=1e10;
int i;
for(i=1;i<=n;i++){
if(i==id)continue;
int c=1;
double aa=(a[i].h1-a[id].h1)/(a[i].xx-a[id].xx);
double bb=(a[i].h2-a[id].h1)/(a[i].xx-a[id].xx);
if(aa<bb)swap(aa,bb),c=0;
if(bb>maxx||aa<minn)
break;
if(aa<maxx){
ansx2=a[i].xx;
if(c)ansy2=a[i].h1;
else ansy2=a[i].h2;
maxx=aa;
}
minn=max(bb,minn);
}
if(i==n+1){
cout<<a[id].xx<<" "<<a[id].h1<<" "<<ansx2<<" "<<ansy2;
return 0;
}
}
return 0;
}