1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include <stdio.h> #include <string.h> #include <algorithm> #include <queue> #include <map> #include <vector> #include <set> #include <string> #include <math.h> using namespace std; const double eps = 1e-8; int (double x) { if(fabs(x) < eps)return 0; if(x < 0) return -1; return 1; } struct Point { double 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); } double operator ^(const Point &b)const { return x*b.y - y*b.x; } double operator *(const Point &b)const { return x*b.x + y*b.y; } }; struct Line { Point s,e; Line(){} Line(Point _s,Point _e) { s = _s;e = _e; } }; double xmult(Point p0,Point p1,Point p2) { return (p1-p0)^(p2-p0); } bool Seg_inter_line(Line l1,Line l2) { return sgn(xmult(l2.s,l1.s,l1.e))*sgn(xmult(l2.e,l1.s,l1.e)) <= 0; } double dist(Point a,Point b) { return sqrt( (b - a)*(b - a) ); } const int MAXN = 110; Line line[MAXN]; bool check(Line l1,int n) { if(sgn(dist(l1.s,l1.e)) == 0 )return false; for(int i = 0;i < n;i++) if(Seg_inter_line(l1,line[i]) == false) return false; return true; } int main() { int n; int T; scanf("%d",&T); while(T--) { scanf("%d",&n); double x1,y1,x2,y2; for(int i = 0; i < n;i++) { scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); line[i] = Line(Point(x1,y1),Point(x2,y2)); } bool flag = false; for(int i = 0;i < n;i++) for(int j = 0; j < n;j++) if(check(Line(line[i].s,line[j].s),n) || check(Line(line[i].s,line[j].e),n) || check(Line(line[i].e,line[j].s),n) || check(Line(line[i].e,line[j].e),n) ) { flag = true; break; } if(flag) printf("Yes!n"); else printf("No!n"); } return 0; }
|
近期评论