最大三角形

#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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章