/* -*- coding: utf-8 -*- * * 199.cc: No.199 星を描こう - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int N = 5; /* typedef */ template struct Pt { T x, y; Pt() {} Pt(T _x, T _y) : x(_x), y(_y) {} Pt(const Pt& pt) : x(pt.x), y(pt.y) {} bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; } Pt operator+(const Pt pt) const { return Pt(x + pt.x, y + pt.y); } Pt operator-() const { return Pt(-x, -y); } Pt operator-(const Pt pt) const { return Pt(x - pt.x, y - pt.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 pt) { return Pt((x + pt.x) / 2, (y + pt.y) / 2); } T d2() { return x * x + y * y; } double d() { return sqrt(d2()); } Pt rot(double th) { double c = cos(th), s = sin(th); return Pt(c * x - s * y, s * x + c * y); } Pt rot90() { return Pt(-y, x); } bool operator<(const Pt& pt) const { return x < pt.x || (x == pt.x && y < pt.y); } void print(string format) { printf(("(" + format + ", " + format + ")\n").c_str(), x, y); } void print() { print("%.6lf"); } }; typedef 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 */ pt pts[N]; bool cm[N][N][N][N]; int pmis[N]; /* subroutines */ bool cross_lines(const pt& ap, const pt av, const pt& bp, const pt bv) { double op01 = av.cross(bv); if (op01 == 0.0) return false; pt v = bp - ap; double op0 = v.cross(av); double op1 = v.cross(bv); double t0 = op1 / op01; double t1 = op0 / op01; CL cl; cl.p = bv * t1 + bp; cl.t0 = t0; cl.t1 = t1; return (0.0 < cl.t0 && cl.t0 < 1.0 && 0.0 < cl.t1 && cl.t1 < 1.0); } /* main */ int main() { for (int i = 0; i < N; i++) cin >> pts[i].x >> pts[i].y; for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) { pt vij = pts[j] - pts[i]; for (int k = 0; k < N; k++) if (k != i && k != j) for (int l = k + 1; l < N; l++) if (l != i && l != j) { pt vkl = pts[l] - pts[k]; if (cross_lines(pts[i], vij, pts[k], vkl)) cm[i][j][k][l] = cm[j][i][k][l] = cm[i][j][l][k] = cm[j][i][l][k] = true; } } for (int i = 0; i < N; i++) pmis[i] = i; do { bool ok = true; int is[N]; for (int i = 0; ok && i < N; i++) { for (int j = 0; j < N; j++) is[j] = pmis[(i + j) % N]; if (! cm[is[0]][is[1]][is[2]][is[3]] || ! cm[is[0]][is[1]][is[3]][is[4]]) ok = false; } if (ok) { puts("YES"); return 0; } } while (next_permutation(pmis, pmis + N)); puts("NO"); return 0; }