Question: n lines are given to determine whether there is a straight line. All lines must have at least one public point after the projection of a straight line (intersection with all lines)
I started to think wrong, because it is to determine whether a line exists in the given line segment to make it intersect with all line segments;
This can also pass the sample input;
I have been searching for it for a day;
# Include <iostream> # include <cmath> # include <cstdlib> # include <cstdio> using namespace STD; const double EPS = 1e-8; const int maxn = 100 + 5; struct point {Double X; Double Y; point (double A = 0, double B = 0) {x = A; y = B ;}} P [maxn * 2]; struct line {Point U; point V;} l; int t, n; int sig (Double X) {return (x> EPS)-(x <-EPS ); // return x <-EPS? -1: x> EPS; // This is also a line} double mult (point P1, point P2) // two-point cross product {return p1.x * p2.y-p1.y * p2.x ;} double mult (point P0, Point P1, point P2) // three-point cross product {return (p1.x-converted X) * (p2.y-converted y)-(p2.x-converted X) * (p1.y-policy);} int same_site (point P1, point P2, line L) // Point P1 & p2 on the same site of line l {int A = sig (mult (L. u, L. v, P1); int B = sig (mult (L. u, L. v, P2); return a * B> 0;} int judge (line L) {If (SIG (L. u. x- L. v. x) = 0 & sig (L. u. y-L. v. y) = 0) return false; For (INT I = 1; I <2 * n; I + = 2) if (same_site (P [I], P [I + 1], L) return false; return true;} int slove () {for (INT I = 1; I <n * 2; I ++) {for (Int J = I + 1; j <= N * 2; j ++) {L. u. X = P [I]. x; L. u. y = P [I]. y; L. v. X = P [J]. x; L. v. y = P [J]. y; If (Judge (L) // if it succeeds, return true;} return false;} int main () is found () {# ifndef online_judge freopen ("in", "r", stdin); # endi F CIN> T; while (t --) {CIN> N; For (INT I = 1; I <= N * 2; I ++) {CIN> P [I]. x> P [I]. y;} If (slove () puts ("Yes! "); Else puts (" No! ");}}