题目只有一行都能读错的淫你伤不起啊……
题意是问存不存在一条直线,让所有的线段在这条直线上的投影的都有公共部分。既然是判断有没有公共部分,那我就直接去找公共部分看找不找得到就好了,反正是投影出来的,也就是说线段和光线必然是有交点的,那就去找看存不存在一条光线被所有的线段都挡住。也转化成,找一条直线和所有线段有有交点。然后直线不是乱找,枚举起点终点直接构造就好了。
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#include <memory>
#include <complex>
#include <numeric>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <locale.h>
using namespace std;
#pragma pack(4)
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x7f7f7f7f;
#define loop(a,n) \
for(int i=0;n>i;i++) \
cout<<a[i]<<(i!=n-1?' ':'\n')
#define loop2(a,n,m) \
for(int i=0;n>i;i++) \
for(int j=0;m>j;j++) \
cout<<a[i][j]<<(j!=m-1?' ':'\n')
#define at(a,i) ((a)&(1<<(i)))
#define nt(a,i) ((a)^(1<<(i)))
#define set1(a,i) ((a)|(1<<(i)))
#define set0(a,i) ((a)&(~(1<<(i))))
#define cmp(a,b) (fabs((a)-(b))<eps?0:(((a)-(b))>eps?+1:-1))
#define lmax(a,b) ((a)>(b)?(a):(b))
#define lmin(a,b) ((a)<(b)?(a):(b))
#define fmax(a,b) (cmp(a,b)>0?(a):(b))
#define fmin(a,b) (cmp(a,b)<0?(a):(b))
const int MAXV = 120;
typedef struct Point
{
double o[2];
double & operator [] (int i)
{
return o[i];
}
friend ostream & operator << (ostream & cout,Point argu)
{
return cout<<"("<<argu[0]<<","<<argu[1]<<"0";
}
Point(double x=0,double y=0)
{
o[0]=x;
o[1]=y;
}
Point operator + (Point argu)
{
return Point(o[0]+argu[0],o[1]+argu[1]);
}
Point operator - (Point argu)
{
return Point(o[0]-argu[0],o[1]-argu[1]);
}
Point operator + (double argu)
{
return (*this)*(1+argu/length());
}
Point operator - (double argu)
{
return (*this)*(1-argu/length());
}
Point operator * (double argu)
{
return Point(o[0]*argu,o[1]*argu);
}
Point operator / (double argu)
{
return Point(o[0]/argu,o[1]/argu);
}
bool operator > (Point argu) const
{
if(cmp(o[0],argu[0])!=0) return cmp(o[0],argu[0])>0;
else return cmp(o[1],argu[1])>0;
}
bool operator >= (Point argu) const
{
if(cmp(o[0],argu[0])!=0) return cmp(o[0],argu[0])>=0;
else return cmp(o[1],argu[1])>=0;
}
bool operator < (Point argu) const
{
if(cmp(o[0],argu[0])!=0) return cmp(o[0],argu[0])<0;
else return cmp(o[1],argu[1])<0;
}
bool operator <= (Point argu) const
{
if(cmp(o[0],argu[0])!=0) return cmp(o[0],argu[0])<=0;
else return cmp(o[1],argu[1])<=0;
}
bool operator != (Point argu) const
{
return cmp(o[0],argu[0])!=0||cmp(o[1],argu[1])!=0;
}
bool operator == (Point argu) const
{
return cmp(o[0],argu[0])==0&&cmp(o[1],argu[1])==0;
}
double length(void)
{
return sqrt(o[0]*o[0]+o[1]*o[1]);
}
double angle(void)
{
return fmod(atan2(o[1],o[0])+2*pi,2*pi);
}
}Vector;
double dot(Vector a,Vector b)
{
return a[0]*b[0]+a[1]*b[1];
}
double dot(Point o,Point a,Point b)
{
return dot(a-o,b-o);
}
int ward(Point p,Point s,Point e)
{
return cmp(dot(s,e,p),0);
}
double cross(Vector a,Vector b)
{
return a[0]*b[1]-a[1]*b[0];
}
double cross(Point o,Point a,Point b)
{
return cross(a-o,b-o);
}
int side(Point p,Point s,Point e)
{
return cmp(cross(s,e,p),0);
}
int n,tcase;
Point s[MAXV],e[MAXV];
bool check(Point a,Point b)
{
if(cmp((a-b).length(),0)==0) return false;
else
{
for(int i=0;n>i;i++)
{
if(side(s[i],a,b)*side(e[i],a,b)>0) return false;
}
return true;
}
}
bool findAns(void)
{
for(int i=0;n>i;i++)
{
for(int j=0;n>j;j++)
{
if(check(s[i],s[j])) return true;
if(check(s[i],e[j])) return true;
if(check(e[i],s[j])) return true;
if(check(e[i],e[j])) return true;
}
}
return false;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("Segments.txt","r",stdin);
#else
#endif
scanf("%d",&tcase);while(tcase--)
{
scanf("%d",&n);
for(int i=0;n>i;i++)
{
scanf("%lf %lf %lf %lf",&s[i][0],&s[i][1],&e[i][0],&e[i][1]);
}
printf("%s\n",findAns()?"Yes!":"No!");
}
return 0;
}