/* -*- coding: utf-8 -*- * * 3154.cc: No.3154 convex polygon judge - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; 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; } T d2() { return x * x + y * y; } 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); } void print() { printf("(%d,%d)", x, y); } }; using pt = Pt; using vpt = vector; /* global variables */ /* subroutines */ // convex_hull() // make a convex_hull 'chs' from a set of points 'ps' // Note: ps must be sorted, and must contain at least 2 points vpt convex_hull(const vpt& ps) { int n = ps.size(); vpt lhs, uhs; lhs.push_back(ps[0]); lhs.push_back(ps[1]); for (int i = 2; i < n; i++) { while (lhs.size() >= 2) { int ln = lhs.size(); pt &lh0 = lhs[ln - 2], &lh1 = lhs[ln - 1]; if ((lh1 - lh0).cross(ps[i] - lh1) > 0) break; lhs.pop_back(); } lhs.push_back(ps[i]); } uhs.push_back(ps[n - 1]); uhs.push_back(ps[n - 2]); for (int i = n - 3; i >= 0; i--) { while (uhs.size() >= 2) { int un = uhs.size(); pt &uh0 = uhs[un - 2], &uh1 = uhs[un - 1]; if ((uh1 - uh0).cross(ps[i] - uh1) > 0) break; uhs.pop_back(); } uhs.push_back(ps[i]); } lhs.pop_back(); uhs.pop_back(); vpt chs; chs.reserve(lhs.size() + uhs.size()); chs.assign(lhs.begin(), lhs.end()); chs.insert(chs.end(), uhs.begin(), uhs.end()); return chs; } /* main */ int main() { int n; scanf("%d", &n); vpt ps(n); for (int i = 0; i < n; i++) scanf("%lld%lld", &ps[i].x, &ps[i].y); sort(ps.begin(), ps.end()); auto chs = convex_hull(ps); if (chs.size() == n) puts("Yes"); else puts("No"); return 0; }