Question link: Click the open link
It should be noted that the mirror is not used as an obstacle when it is collocated with two people, but it is consistent with the wall in other situations.
# Include <cstdio> # include <iostream> # include <algorithm> # include <string. h> # include <math. h> using namespace STD; # define point pointconst double EPS = 1e-8; const double Pi = ACOs (-1.0); double ABS (Double X) {return x> 0? X:-X;} int SGN (Double X) {If (FABS (x) <EPS) return 0; If (x <0) Return-1; else return 1 ;} struct point {Double X, Y; void put () {printf ("(%. 0lf, %. 0lf) \ n ", x, y);} Point () {} Point (double _ x, double _ y) {x = _ x; y = _ y ;} point operator-(const point & B) const {return point (X-B. x, Y-B. y);} // Cross Product double operator ^ (const point & B) const {return x * B. y-y * B. x;} // dot product double operator * (const point & B) const {return x * B. X + Y * B. Y ;}/ /Rotate the angle B (radian value) around the origin, and change void transxy (double B) after X and Y {double Tx = x, Ty = y; X = TX * Cos (B)-ty * sin (B); y = TX * sin (B) + ty * Cos (B );}}; struct line {point S, E; void put () {S. put (); E. put ();} line () {} line (point _ s, point _ e) {S = _ s; E = _ E ;} // calculates the intersection of two straight lines. // if the first value is 0, the line is overlapped. If the value is 1, the line is parallel. If the value is 0, the line is intersecting, 2 is the intersection. // The intersection is meaningful when the first value is 2. Pair <int, point> operator & (const line & B) const {point res = s; if (SGN (S-e) ^ (B. s-b.e) = 0) {If (SGN (s-b.e) ^ (B. s-b.e) = 0) return make_pair (0, Res); // coincidence else return make_pair (1, Res); // parallel} double T = (s-b.s) ^ (B. s-b.e)/(S-e) ^ (B. s-b.e); Res. X + = (E. x-s.x) * t; Res. Y + = (E. y-s.y) * t; return make_pair (2, Res) ;}}; double dist (point a, point B) {return SQRT (a-B) * (a-B);} // * determines the intersection of line segments bool inter (line L1, line l2) {returnmax (l1.s. x, l1.e. x)> = min (l2.s. x, l2.e. x) & MAX (l2.s. x, l2.e. x)> = min (l1.s. x, l1.e. x) & MAX (l1.s. y, l1.e. y)> = min (l2.s. y, l 2. e. y) & MAX (l2.s. y, l2.e. y)> = min (l1.s. y, l1.e. y) & SGN (l2.s-l1.e) ^ (l1.s-l1.e) * SGN (l2.e-l1.e) ^ (l1.s-l1.e )) <= 0 & SGN (l1.s-l2.e) ^ (l2.s-l2.e) * SGN (l1.e-l2.e) ^ (l2.s-l2.e) <= 0 ;} point into ric_point (point P1, point L1, point L2) {point ret; If (ABS (l1.x-l2.x) <EPS) {ret. y = p1.y; ret. X = 2 * l1.x-p1.x; return ret;} If (ABS (l1.y-l2.y) <EPS) {ret. X = p1.x; ret. y = 2 * l1.y-p1.y; return ret;} If (l1.x> l2.x -EPS & l1.x <l2.x + EPS) {ret. X = (2 * l1.x-p1.x); ret. y = p1.y;} else {Double K = (l1.y-l2.y)/(l1.x-l2.x); ret. X = (2 * K * l1.x + 2 * K * p1.y-2 * K * l1.y-K * p1.x + p1.x)/(1 + K * k ); ret. y = p1.y-(Ret. x-p1.x)/K;} return ret;} bool Gongxian (point a, point B, point C) {return ABS (. y-b.y) * (. x-c.x)-(. y-c.y) * (. x-b.x) <EPS;} Point A, B; line PEO, Wal, Mir; bool work () {// PEO. put (); WAL. put (); If (Gongxian (A, Mir. s, Mir. e) & Gongxian (B, Mir. s, Mir. e) {//. put (); B. put (); Mir. put (); puts ("collocated"); return! Inter (Wal, PEO);} else if (Inter (MIR, PEO) return false; If (! Inter (Wal, PEO) return true; // puts ("Gege"); If (Inter (Wal, Mir) return false; point c = effecric_point (B, Mir. s, Mir. e); point D = pairic_point (A, Mir. s, Mir. e); // C. put (); D. put (); line AC, BD; AC. S = A, AC. E = C; BD. S = B, Bd. E = D; If (! Inter (AC, Mir) return false; If (! Inter (BD, Mir) return false; If (Inter (AC, wal) return false; If (Inter (BD, wal) return false; return true ;} int main () {While (~ Scanf ("% lf", &. x, &. y) {scanf ("% lf", & B. x, & B. y); scanf ("% lf", & Wal. s. x, & Wal. s. y, & Wal. e. x, & Wal. e. y); scanf ("% lf", & Mir. s. x, & Mir. s. y, & Mir. e. x, & Mir. e. y); PEO. S = A, PEO. E = B; Work ()? Puts ("yes"): puts ("no");} return 0 ;}