/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 1ms 308.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 316.0 KiB
#4 Accepted 1ms 316.0 KiB
#5 Accepted 1ms 488.0 KiB
#6 Accepted 1ms 312.0 KiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 316.0 KiB
#9 Accepted 1ms 312.0 KiB
#10 Accepted 1ms 308.0 KiB
#11 Accepted 1ms 320.0 KiB
#12 Accepted 1ms 308.0 KiB
#13 Accepted 2ms 308.0 KiB
#14 Accepted 1ms 320.0 KiB
#15 Accepted 1ms 316.0 KiB
#16 Accepted 1ms 308.0 KiB
#17 Accepted 1ms 316.0 KiB
#18 Accepted 1ms 312.0 KiB
#19 Accepted 1ms 312.0 KiB
#20 Accepted 1ms 316.0 KiB
#21 Accepted 1ms 312.0 KiB
#22 Accepted 1ms 320.0 KiB
#23 Accepted 1ms 320.0 KiB
#24 Accepted 1ms 304.0 KiB
#25 Accepted 1ms 316.0 KiB
#26 Accepted 1ms 316.0 KiB
#27 Accepted 1ms 312.0 KiB
#28 Accepted 1ms 308.0 KiB
#29 Accepted 1ms 324.0 KiB
#30 Accepted 1ms 312.0 KiB
#31 Accepted 1ms 308.0 KiB
#32 Accepted 1ms 316.0 KiB
#33 Accepted 1ms 320.0 KiB
#34 Accepted 1ms 312.0 KiB
#35 Accepted 1ms 320.0 KiB
#36 Accepted 1ms 316.0 KiB
#37 Accepted 1ms 316.0 KiB
#38 Accepted 1ms 316.0 KiB
#39 Accepted 1ms 312.0 KiB
#40 Accepted 1ms 308.0 KiB
#41 Accepted 1ms 324.0 KiB
#42 Accepted 1ms 308.0 KiB
#43 Accepted 1ms 312.0 KiB
#44 Accepted 1ms 324.0 KiB
#45 Accepted 1ms 312.0 KiB
#46 Accepted 1ms 312.0 KiB
#47 Accepted 1ms 320.0 KiB
#48 Accepted 1ms 316.0 KiB
#49 Accepted 1ms 316.0 KiB
#50 Accepted 1ms 316.0 KiB
#51 Accepted 1ms 316.0 KiB
#52 Accepted 1ms 312.0 KiB
#53 Accepted 1ms 320.0 KiB
#54 Accepted 1ms 308.0 KiB
#55 Accepted 1ms 316.0 KiB
#56 Accepted 1ms 316.0 KiB
#57 Accepted 1ms 308.0 KiB
#58 Accepted 1ms 308.0 KiB
#59 Accepted 1ms 324.0 KiB
#60 Accepted 1ms 316.0 KiB
#61 Accepted 1ms 312.0 KiB
#62 Accepted 1ms 312.0 KiB
#63 Accepted 1ms 312.0 KiB
#64 Accepted 1ms 320.0 KiB
#65 Accepted 1ms 320.0 KiB
#66 Accepted 1ms 308.0 KiB
#67 Accepted 1ms 316.0 KiB
#68 Accepted 1ms 312.0 KiB
#69 Accepted 1ms 312.0 KiB
#70 Accepted 1ms 316.0 KiB
#71 Accepted 1ms 324.0 KiB
#72 Accepted 1ms 304.0 KiB
#73 Accepted 1ms 304.0 KiB
#74 Accepted 1ms 316.0 KiB
#75 Accepted 1ms 316.0 KiB
#76 Accepted 1ms 308.0 KiB
#77 Accepted 1ms 320.0 KiB
#78 Accepted 1ms 316.0 KiB
#79 Accepted 1ms 320.0 KiB
#80 Accepted 1ms 316.0 KiB

代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const double eps=1e-8;
int sgn(double a)
{
    if (fabs(a)<eps) return 0;
    else
    {
        if (a>0.0) return 1;
        else return -1;
    }
}
struct point
{
    double x,y;
    point(){}
    point(double a,double b)
    {
        x=a;y=b;
    }
    void init()
    {
        scanf("%lf%lf",&x,&y);
    }
    point operator+(const point &a)const
    {
        point ans;
        ans.x=x+a.x;
        ans.y=y+a.y;
        return ans;
    }
    point operator-(const point &a)const
    {
        point ans;
        ans.x=x-a.x;
        ans.y=y-a.y;
        return ans;
    }
    point operator*(const double &a)const
    {
        point ans;
        ans.x=x*a;
        ans.y=y*a;
        return ans;
    }
    void print()
    {
        printf("%lf %lf\n",x,y);
    }
}v,p,w1,w2,m1,m2;
double cross(point a,point b)
{
    return a.x*b.y-a.y*b.x;
}
double dot(point a,point b)
{
    return a.x*b.x+a.y*b.y;
}
bool cross(point p1,point p2,point p3,point p4)
{
    if (sgn(cross(p2-p1,p3-p1))*sgn(cross(p2-p1,p4-p1))==1) return false;
    if (sgn(cross(p4-p3,p1-p3))*sgn(cross(p4-p3,p2-p3))==1) return false;
    if (sgn(max(p1.x,p2.x)-min(p3.x,p4.x))==-1) return false;
    if (sgn(max(p1.y,p2.y)-min(p3.y,p4.y))==-1) return false;
    if (sgn(max(p3.x,p4.x)-min(p1.x,p2.x))==-1) return false;
    if (sgn(max(p3.y,p4.y)-min(p1.y,p2.y))==-1) return false;
    return true;
}
point getcross(point p1,point p2,point p3,point p4)
{
    double a=p2.y-p1.y;
    double b=p1.x-p2.x;
    double c=-p1.x*p2.y+p1.y*p2.x;
    double d=p4.y-p3.y;
    double e=p3.x-p4.x;
    double f=-p3.x*p4.y+p3.y*p4.x;
    double x=(b*f-c*e)/(a*e-b*d);
    double y=(a*f-c*d)/(b*d-a*e);
    return point(x,y);
}
point calcfoot(point p1,point p2,point p3)
{
    double ratio=dot(p1-p2,p3-p2)/dot(p3-p2,p3-p2);
    return p2+(p3-p2)*ratio;
}
bool check()
{
    if (!cross(v,p,w1,w2))
    {
        if (!cross(v,p,m1,m2)) return true;
        if (sgn(cross(m1-v,m2-v))==0 && sgn(cross(m1-p,m2-p)==0)) return true;      
    }
    if (sgn(cross(m2-m1,v-m1))*sgn(cross(m2-m1,p-m1))==1)
    {
        point foot=calcfoot(p,m1,m2);
        foot=foot*2.0-p;
        if (cross(v,foot,m1,m2))
        {
            foot=getcross(v,foot,m1,m2);
            if (!cross(v,foot,w1,w2) && !cross(foot,p,w1,w2)) return true;
        }
    }
    return false;
}
int main()
{
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
    v.init();
    p.init();
    w1.init();
    w2.init();
    m1.init();
    m2.init();
    if (check()) printf("YES\n");
    else printf("NO\n");
    return 0;
}

信息

递交者
类型
递交
题目
二人对视 T2
题目数据
下载
语言
C++
递交时间
2017-10-01 14:15:31
评测时间
2017-10-01 14:18:47
评测机
分数
100
总耗时
125ms
峰值内存
488.0 KiB