#include #include #include #define X first #define Y second using namespace std; typedef pair point; typedef pair segment; const double eps = 1e-7; point operator+(const point &p1, const point &p2) { return point(p1.X + p2.X, p1.Y + p2.Y); } point operator-(const point &p1, const point &p2) { return point(p1.X - p2.X, p1.Y - p2.Y); } point operator*(const double &coe, const point &p) { return point(p.X * coe, p.Y * coe); } double operator^(const point &u, const point &v) { return u.X * v.Y - u.Y * v.X; } string direction(const point &p1, const point &p2, const point &p3); bool haveIntersection(const segment &s1, const segment &s2); point intersection(const segment &s1, const segment &s2); int main() { return 0; } string direction(const point &p1, const point &p2, const point &p3) { point u = p2 - p1, v = p3 - p1; double crossProduct = u^v; if (abs(crossProduct) < eps) return "straight"; return crossProduct < 0? "right": "left"; } bool haveIntersection(const segment &s1, const segment &s2) { bool q1 = (direction(s1.first, s1.second, s2.first) != direction(s1.first, s1.second, s2.second)); bool q2 = (direction(s2.first, s2.second, s1.first) != direction(s2.first, s2.second, s1.second)); return q1 && q2; } point intersection(const segment &s1, const segment &s2) { point u = s1.second - s1.first, v = s2.second - s2.first; double alpha = ((s2.first - s1.first)^v) / (u^v); return alpha * u + s1.first; }