Untitled
unknown
plain_text
a year ago
1.4 kB
12
Indexable
Never
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; struct Point { int x, y; Point(){} Point(int x1, int y1) { x = x1; y = y1; } bool operator < (const Point &other) { return make_pair(x, y) < make_pair(other.x, other.y); } bool operator == (const Point &other) { return make_pair(x, y) == make_pair(other.x, other.y); } }; struct Segment { Point a, b; Segment(){} Segment(Point a1, Point b1) { a = a1; b = b1; } const bool isH() { return a.y == b.y; } bool operator < (const Segment &o) const { bool isH = (a.y == b.y); bool oisH = (o.a.y == o.b.y); if (isH && !oisH) return true; if (!isH && oisH) return false; if (isH && oisH) { return (a.y < o.a.y); } return a.x < o.a.x; } }; Segment s[4]; int main() { bool ok = 1; for (int i = 0; i < 4; i++) { Point a, b; cin >> a.x >> a.y; cin >> b.x >> b.y; if (b < a) swap(a, b); s[i] = Segment(a, b); ok &= !(a == b); } sort(s, s + 4); if (!s[0].isH() || !s[1].isH() || s[2].isH() || s[3].isH()) { ok = 0; } else { ok &= (s[0].a == s[2].a && s[2].b == s[1].a && s[1].b == s[3].b && s[3].a == s[0].b); } if (ok) cout << "YES\n"; else cout << "NO\n"; return 0; }