/* -*- coding: utf-8 -*- * * 3005.cc: No.3005 繝医Ξ繝溘・縺ョ蝠城。・- yukicoder */ #include #include using namespace std; /* constant */ const double DELTA = 1e-8; /* typedef */ template struct Pt { T x, y; Pt() {} Pt(T _x, T _y) : x(_x), y(_y) {} Pt(const Pt &p) : x(p.x), y(p.y) {} Pt operator+(const Pt p) const { return Pt(x + p.x, y + p.y); } Pt operator-() const { return Pt(-x, -y); } Pt operator-(const Pt p) const { return Pt(x - p.x, y - p.y); } Pt operator*(T t) const { return Pt(x * t, y * t); } Pt operator/(T t) const { return Pt(x / t, y / t); } T dot(Pt v) const { return x * v.x + y * v.y; } T cross(Pt v) const { return x * v.y - y * v.x; } Pt mid(const Pt p) { return Pt((x + p.x) / 2, (y + p.y) / 2); } T d2() { return x * x + y * y; } double d() { return sqrt(d2()); } Pt rot90() { return Pt(-y, x); } bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; } bool operator<(const Pt &pt) const { return x < pt.x || (x == pt.x && y < pt.y); } }; using pt = Pt; struct CL { pt p; double t0, t1; CL() {} CL(const pt& _p, double _t0, double _t1) : p(_p), t0(_t0), t1(_t1) {} }; /* global variables */ /* subroutines */ bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv, CL& cl) { double op01 = av.cross(bv); //if (op01 == 0.0) return false; /* need to handle parallel?? */ if (op01 == 0.0) { pt v = bp - ap; if (v.cross(av) != 0.0) return false; pt a1 = ap + av; pt b1 = bp + bv; return ((bp - ap).dot(b1 - ap) <= 0.0 || (bp - a1).dot(b1 - a1) <= 0.0 || (ap - bp).dot(a1 - bp) <= 0.0 || (ap - b1).dot(a1 - b1) <= 0.0); } pt v = bp - ap; double op0 = v.cross(av); double op1 = v.cross(bv); double t0 = op1 / op01; double t1 = op0 / op01; cl.p = bv * t1 + bp; cl.t0 = t0; cl.t1 = t1; return true; //return (0.0 <= cl.t0 && cl.t0 <= 1.0 && 0.0 <= cl.t1 && cl.t1 <= 1.0); } void readpt(pt &a) { scanf("%lf%lf", &a.x, &a.y); } /* main */ int main() { pt a, b, c, d; readpt(a), readpt(b), readpt(c), readpt(d); pt v0(b - a), v1(c - a); if (v0.cross(v1) == 0.0) { puts("NO"); return 0; } pt p0 = v0 * 0.5 + a, p1 = v1 * 0.5 + a; pt nv0 = v0.rot90(), nv1 = v1.rot90(); CL cl; cross_lines(p0, nv0, p1, nv1, cl); //printf(" %lf,%lf\n", cl.p.x, cl.p.y); double rr0 = (a - cl.p).d2(), rr1 = (d - cl.p).d2(); if (abs(rr1 - rr0) < DELTA) puts("YES"); else puts("NO"); return 0; }