最大三角形

来源:互联网 发布:服务贸易数据 编辑:程序博客网 时间:2024/06/10 18:47
#include <bits/stdc++.h>using namespace std;typedef long long ll;ll read(){    ll ret=0;    char ch=getchar();    while(ch<'0'||ch>'9') ch=getchar();    for(; ch>='0'&&ch<='9'; ch=getchar()) ret=ret*10+ch-'0';    return ret;}ll readf(){    ll t=0,flag=1;    char c=getchar();    while(c<'0'||c>'9'||c=='-')    {        if(c=='-')flag=-1;        c=getchar();    }    while(c>='0'&&c<='9')    {        t=t*10+c-'0';        c=getchar();    }    return t*flag;}struct node{    ll x,y;};ll cross(node a,node b,node c){    return abs((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x));}vector<node> q;int main(){    ll n=read(),s=read();    for(int i=1;i<=n;i++)    {        node p;        p.x=readf(),p.y=readf();        q.push_back(p);    }    node a,b,c;    a=q[0],b=q[1],c=q[2];    ll ans=cross(a,b,c);    int flag=1;    while(flag)    {        flag=0;        for(int i=0;i<q.size();i++)        {            ll tmp=cross(q[i],b,c);            if(tmp>ans)                ans=tmp,a=q[i],flag=1;            tmp=cross(a,q[i],c);            if(tmp>ans)                ans=tmp,b=q[i],flag=1;            tmp=cross(a,b,q[i]);            if(tmp>ans)                ans=tmp,c=q[i],flag=1;        }    }    cout<<a.x+b.x-c.x<<" "<<a.y+b.y-c.y<<endl;    cout<<a.x+c.x-b.x<<" "<<a.y+c.y-b.y<<endl;    cout<<b.x+c.x-a.x<<" "<<b.y+c.y-a.y<<endl;}