The Great Divide, which determines whether two convex packets are separated.
Calculate Two convex packets from the given two vertex sets,
Then determine whether the two convex packets are separated.
# Include
# Include
# Include
# Define deusing namespace std; const double eps = 1e-10; double dcmp (double x) {if (fabs (x) <eps) return 0; else return x <0? -1: 1 ;}struct Point {double x, y; Point (double x = 0, double y = 0): x (x), y (y ){}}; typedef Point Vector; Vector operator-(const Point & A, const Point & B) {return Vector (. x-B.x,. y-B.y);} double Cross (const Vector & A, const Vector & B) {return. x * B. y-. y * B. x;} double Dot (const Vector & A, const Vector & B) {return. x * B. x +. y * B. y;} bool operator <(const Point & p1, const Point & p2) {return p1.x <p2.x | (p1.x = p2.x & p1.y <p2.y );} bool operator = (const Point & p1, const Point & p2) {return p1.x = p2.x & p1.y = p2.y;} bool SegmentProperIntersection (const Point & a1, const Point & a2, const Point & b1, const Point & b2) {double c1 = Cross (a2-a1, b1-a1), c2 = Cross (a2-a1, b2-a1 ), c3 = Cross (b2-b1, a1-b1), c4 = Cross (b2-b1, a2-b1); return dcmp (c1) * dcmp (c2) <0 & dcmp (c3) * dcmp (c4) <0;} bool OnSegment (const Point & p, const Point & a1, const Point & a2) {return dcmp (Cross (a1-p, a2-p )) = 0 & dcmp (Dot (a1-p, a2-p) <0 ;}// Point Set convex hull // if you do not want an Input Point on the side of the convex hull, change the two <=
ConvexHull (vector
P) {// pre-process and delete the repeated vertex sort (p. begin (), p. end (); p. erase (unique (p. begin (), p. end (), p. end (); int n = p. size (); int m = 0; vector
Ch (n + 1); for (int I = 0; I <n; I ++) {while (m> 1 & Cross (ch [s-1]-ch [m-2], p [I]-ch [m-2]) <= 0) m --; ch [m ++] = p [I];} int k = m; for (int I = n-2; I> = 0; I --) {while (m> k & Cross (ch [s-1]-ch [m-2], p [I]-ch [m-2]) <= 0) m --; ch [m ++] = p [I];} if (n> 1) m --; ch. resize (m); return ch;} int IsPointInPolygon (const Point & p, const vector
& Poly) {int wn = 0; int n = poly. size (); for (int I = 0; I
0 & d1 <= 0 & d2> 0) wn ++; if (k <0 & d2 <= 0 & d1> 0) wn --;} if (wn! = 0) return 1; return 0;} bool ConvexPolygonDisjoint (const vector
Vector, const vector
Ch2) {int c1 = ch1.size (); int c2 = ch2.size (); for (int I = 0; I
0 & m> 0) {vector
P1, P2; double x, y; for (int I = 0; I <n; I ++) {scanf ("% lf", & x, & y); P1.push _ back (Point (x, y) ;}for (int I = 0; I <m; I ++) {scanf ("% lf", & x, & y); P2.push _ back (Point (x, y);} if (ConvexPolygonDisjoint (ConvexHull (P1 ), convexHull (P2) printf ("Yes \ n"); else printf ("No \ n");} return 0 ;}