#include <cstdio>
#include <cmath>
const int maxn = 600 + 10;
const double eps = 1e-8;
struct Point
{
double x, y;
Point(double x=0, double y=0):x(x), y(y) {}
}p[maxn];
int dcmp(double x)
{
if(fabs(x) < eps) return 0;
return x < 0 ? -1 : 1;
}
Point operator - (const Point& a, const Point& b)
{ return Point(a.x-b.x, a.y-b.y); }
double Cross(const Point& a, const Point& b)
{ return (a.x*b.y - a.y*b.x); }
bool operator == (const Point& a, const Point& b)
{ return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0; }
bool intersect(const Point& a, const Point& b, const Point& p1, const Point& p2)
{
int d1 = dcmp(Cross(b-a, p1-a));
int d2 = dcmp(Cross(b-a, p2-a));
if(d1 == 0 || d2 == 0) return true;
if(d1 * d2 < 0) return true;
return false;
}
int main(void)
{
//freopen("3492in.txt", "r", stdin);
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
for(int i = 0; i < 2*n-1; i += 2)
scanf("%lf%lf%lf%lf", &p[i].x, &p[i].y, &p[i+1].x, &p[i+1].y);
bool exist = false;
bool issame = true;
for(int i = 0; i < 2*n-1 && !exist; ++i)
{
for(int j = i+1; j < 2*n && !exist; ++j)
{
if(p[i] == p[j]) continue;
issame = false;
int k;
for(k = 0; k < 2*n; k += 2)
if(!intersect(p[i], p[j], p[k], p[k+1])) break;
if(k == 2 * n)
exist = true;
}
}
if(exist || issame) puts("Yes");
else puts("No");
}
return 0;
}
tjut 3492
最新推荐文章于 2016-11-04 22:02:44 发布