ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题解汇总 Territorial Dispute

A:模拟水题
http://blog.csdn.net/axuhongbo/article/details/78074877
E:计算几何,比赛时候队友暴力枚举过去的,但觉得凸包做更普遍一些,贴个凸包模板
http://www.cnblogs.com/Just–Do–It/p/7582228.html
这个是比较清楚一点的
http://blog.csdn.net/creatorx/article/details/78072775
下面是我队友写的

#include 
#include
#include
#include 
#include 
using namespace std;
const double eps=1e-8;

int sgn(double x)
{
    if(fabs(x)return 0;
    if(x<0)return -1;
    return 1;
}

struct point
{
    double x,y;
};

struct line
{
    point s,e;
};
double mul(point sp,point ep,point op)
{
    return ((sp.x-op.x)*(ep.y-op.y)-(ep.x-op.x)*(sp.y-op.y));
}

bool inter(line u ,line v)
{
    return ((max(u.s.x,u.e.x)>=min(v.s.x,v.e.x))&&
            (max(v.s.x,v.e.x)>=min(u.s.x,u.e.x))&&
            (max(u.s.y,u.e.y)>=min(v.s.y,v.e.y))&&
            (max(v.s.y,v.e.y)>=min(u.s.y,u.e.y))&&
            (mul(v.s,u.e,u.s)*mul(u.e,v.e,u.s)>=0)&&
            (mul(u.s,v.e,v.s)*mul(v.e,u.e,v.s)>=0));
}



double dist(double x1,double y1,double x2,double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

double mian(double x1,double y1,double x2,double y2,double x3,double y3)
{
    double d1,d2,d3,p;
    d1=dist(x1,y1,x2,y2);
    d2=dist(x2,y2,x3,y3);
    d3=dist(x1,y1,x3,y3);
    p=(d1+d2+d3)/2;
    return sqrt(p*(p-d1)*(p-d2)*(p-d3));
}

int main()
{
    double x[110],y[110];
    int t,n,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(i=0;iscanf("%lf%lf",&x[i],&y[i]);
        }
        if(n<3){printf("NO\n");continue;}
        if(n==3)
        {
            if((y[1]-y[0])*(x[2]-x[0])==(x[1]-x[0])*(y[2]-y[0]))
            {
                printf("YES\n");
                double d0,d1,d2;
                d0=dist(x[1],y[1],x[2],y[2]);
                d1=dist(x[0],y[0],x[2],y[2]);
                d2=dist(x[1],y[1],x[0],y[0]);
                if(d0==d1+d2)printf("BAA\n");
                else if(d1==d0+d2)printf("ABA\n");
                else printf("AAB\n");
            }
            else printf("NO\n");
            continue;
        }
        if(n>=4)
        {
            printf("YES\n");
            if((y[1]-y[0])*(x[2]-x[0])==(x[1]-x[0])*(y[2]-y[0]))
            {
                double d0,d1,d2;
                d0=dist(x[1],y[1],x[2],y[2]);
                d1=dist(x[0],y[0],x[2],y[2]);
                d2=dist(x[1],y[1],x[0],y[0]);
                if(d0==d1+d2)printf("BAA");
                else if(d1==d0+d2)printf("ABA");
                else printf("AAB");
                for(i=0;i3;i++)printf("A");
                printf("\n");
            }
            else
            {
                double s0,s1,s2,s3;
                s3=mian(x[0],y[0],x[1],y[1],x[2],y[2]);
                s2=mian(x[0],y[0],x[1],y[1],x[3],y[3]);
                s1=mian(x[0],y[0],x[3],y[3],x[2],y[2]);
                s0=mian(x[3],y[3],x[1],y[1],x[2],y[2]);
                if(sgn(s0+s1+s2-s3)==0)printf("AAAB");
                else if(sgn(s0+s1-s2+s3)==0)printf("AABA");
                else if(sgn(s0-s1+s2+s3)==0)printf("ABAA");
                else if(sgn(s0-s1-s2-s3)==0)printf("ABBB");
                else
                {
                    point a,b,c,d;
                    a.x=x[0];
                    a.y=y[0];
                    b.x=x[1];
                    b.y=y[1];
                    c.x=x[2];
                    c.y=y[2];
                    d.x=x[3];
                    d.y=y[3];
                    line ab,ac,ad,bc,bd,cd;
                    ab.e=a;
                    ab.s=b;
                    ac.e=a;
                    ac.s=c;
                    ad.e=a;
                    ad.s=d;
                    bc.e=c;
                    bc.s=b;
                    bd.e=d;
                    bd.s=b;
                    cd.e=d;
                    cd.s=c;
                    if(inter(ab,cd))printf("AABB");
                    else if(inter(ac,bd))printf("ABAB");
                    else if(inter(ad,bc))printf("ABBA");
                }
                for(i=0;i4;i++)printf("A");
                printf("\n");
            }
        }
    }
}

I 线段树模板题:
http://blog.csdn.net/lzc504603913/article/details/78072624

G 找规律,比赛时一直卡在这里
同校队伍有用扩展欧几里得过的
贴一个拓展欧几里得算法的介绍
http://blog.csdn.net/zhjchengfeng5/article/details/7786595
下面还有两个大佬的博客
http://www.cnblogs.com/Just–Do–It/p/7583613.html
这个介绍的比较详细,但是感觉还是有点玄,好多很显然
https://www.q-cs.cn/2017/09/23/bounce2017-acm-%E5%8C%97%E4%BA%AC%E7%AB%99%E7%BD%91%E7%BB%9C%E8%B5%9B/

你可能感兴趣的:(2017,ACM-ICPC,亚洲区,网络赛)