Magic Line

Magic Line

Metaphysical through series title, all randomly selected points in the lower left point, and the other sort of point slope taken slope between two points intermediate

Competition, not enough random == bottom left point, resulting in no card in the past

#include<bits/stdc++.h>
using namespace std;
int t,n;
typedef long long ll;
#define P pair<ll,ll>
#define fi first
#define se second
P A[1005];
ll mx,my;
bool cmp(P a,P b)
{
    return a.se*b.fi>a.fi*b.se;
}
 
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        srand(time(NULL));
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
        {
            scanf("%lld%lld",&A[i].fi,&A[i].se);
            if(i==0)mx=A[i].fi,my=A[i].se;
            mx=min(A[i].fi,mx);
            my=min(A[i].se,my);
        }
        mx-=rand()%10015+1;
        my-=rand()%10015+1;
        for(int i=1;i<=n;i++){
            A[i].fi-=mx;
            A[i].se-=my;
        }
        sort(A+1,A+n+1,cmp);
        P a=A[n/2],b=A[n/2+1];
        cout<<mx<<' '<<my<<' ';
        ll x=a.fi+b.fi;
        ll y=a.se+b.se;
        cout<<x+mx<<' '<<y+my<<'\n';
    }
}

 

Guess you like

Origin www.cnblogs.com/liulex/p/11248097.html