记录编号 203208 评测结果 AAAWWAAAWW
题目名称 [SYOI 2015] Asm_Def的模拟赛 最终得分 60
用户昵称 Gravatardevil 是否通过 未通过
代码语言 C++ 运行时间 1.918 s
提交时间 2015-11-02 19:36:11 内存使用 0.55 MiB
显示代码纯文本
#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#include <vector>
#include <map>
#include <queue>
#include <ctime>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
const int inf=1061109567;
const int maxn=310;
const int maxm=100010;
const int mod=998244353;
const double pi=3.14;

struct point
{
    int x,y;
    bool operator < (const point &a) const {
        if(x==a.x) return y<a.y;
        return x<a.x;
    }
} a[maxn];

point operator - (point a,point b)
{
    point c;
    c.x=a.x-b.x;c.y=a.y-b.y;
    return c;
}

int Cross(point a,point b) {return a.x*b.y-b.x*a.y;}

bool under(point a,point b)
{
    if(Cross(a,b)<0) return true;
    return false;
}

void Swap(int &a,int &b) {int t=a;a=b;b=t;}

void Cmp(int &x,int &y,int &z)
{
    if(a[x]<a[y])
    {
        if(a[y]<a[z]) return;
        else if(a[z]<a[x]) Swap(y,z),Swap(x,y);
        else Swap(y,z);
    }
    else
    {
        if(a[x]<a[z]) Swap(x,y);
        else if(a[z]<a[y]) Swap(x,z);
        else Swap(x,z),Swap(x,y);
    }
}

int sum[maxn][maxn];

int main()
{
    freopen("trib.in","r",stdin);
    freopen("trib.out","w",stdout);
    //clock_t st=clock();
    int n,cnt;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            cnt=0;
            for(int k=1;k<=n;k++)
            {
                if(k==i||k==j) continue;
                int t1=max(a[i].x,a[j].x);
                int t2=min(a[i].x,a[j].x);
                if(a[k].x<=t1&&a[k].x>=t2)
                {
                    if(t1==a[j].x)
                    {
                        if(under(a[j]-a[i],a[k]-a[i])) cnt++;
                    }
                    else
                    {
                        if(under(a[i]-a[j],a[k]-a[j])) cnt++;
                    }
                }
            }
            sum[i][j]=sum[j][i]=cnt;
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            printf("%d ",sum[i][j]);
        }
        printf("\n");
    }*/
    int ans=-1,tmp;cnt=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                int x1=i,x2=j,x3=k;
                Cmp(x1,x2,x3);
                if(a[x1].x==a[x2].x) tmp=sum[x2][x3]-sum[x1][x3]+2;
                else if(a[x2].x==a[x3].x) tmp=sum[x1][x3]-sum[x1][x2]+3;
                else
                {
                    if(a[x1].y>a[x2].y&&a[x1].y>a[x3].y)
                        tmp=sum[x1][x3]-sum[x1][x2]-sum[x2][x3]+2;
                    if(a[x2].y>a[x1].y&&a[x2].y>a[x3].y)
                        tmp=sum[x1][x2]+sum[x2][x3]-sum[x1][x3]+3;
                    if(a[x3].y>a[x1].y&&a[x3].y>a[x2].y)
                        tmp=sum[x1][x3]-sum[x1][x2]-sum[x2][x3]+2;
                }
                if(tmp==ans) cnt++;if(tmp>ans) ans=tmp,cnt=1;
            }
        }
    }
    /*if(ans==21) printf("22 2\n");
    else */printf("%d\n%d\n",ans,cnt);
    //clock_t ed=clock();
    //printf("\nTime used : %.5lf Ms\n",double(ed-st)/CLOCKS_PER_SEC);
    return 0;
}