106 lines
1.9 KiB
C++
106 lines
1.9 KiB
C++
#include<iostream>
|
|
#include<cstdio>
|
|
#include<cmath>
|
|
#include<cstring>
|
|
using namespace std;
|
|
const double inf=1e100,EPS=1e-6;
|
|
const int N=5;
|
|
double cr0,cr1;
|
|
int n,s,j,bx[2],by[2],init;
|
|
struct xy
|
|
{
|
|
int x,y;
|
|
} v[N],d[N],e[2];
|
|
//WA double 判断正负要用
|
|
int sign(double d)
|
|
{
|
|
if(fabs(d)<EPS)
|
|
{
|
|
return 0;
|
|
}
|
|
else return d>0? 1:-1;
|
|
}
|
|
double cross(double x1,double y1,double x2,double y2)
|
|
{
|
|
return x1*y2-x2*y1;
|
|
}
|
|
int same(double x0,double y0,double x3,double y3,double x1,double y1,double x2,double y2)
|
|
{
|
|
double x=x3-x0,y=y3-y0;//y0->x0
|
|
int a=sign(cross(x,y,x1-x0,y1-y0)),b=sign(cross(x,y,x2-x0,y2-y0));
|
|
//WA*N 两条线段是在同一直线上的但是没有重合部分,那么通过跨立实验返回的是相交,就错了,必须再加上快速排斥
|
|
if(a==0&&b==0)
|
|
{
|
|
if(max(x0,x3)<min(x1,x2)||min(x0,x3)>max(x1,x2)||max(y0,y3)<min(y1,y2)||min(y0,y3)>max(y1,y2))
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
if(a<0&&b<0)
|
|
{
|
|
return 2;
|
|
}
|
|
return a*b;
|
|
}
|
|
int main()
|
|
{
|
|
scanf("%d",&n);
|
|
while(n--)
|
|
{
|
|
for(int i=0; i<2; i++)
|
|
{
|
|
scanf("%d%d",&e[i].x,&e[i].y);//&又忘了
|
|
}
|
|
for(int i=0; i<2; i++)
|
|
{
|
|
scanf("%d%d",&bx[i],&by[i]);
|
|
}
|
|
for(int i=1; i<N; i++)
|
|
{
|
|
if(i<3)d[i].x=min(bx[0],bx[1]);
|
|
else d[i].x=max(bx[0],bx[1]);
|
|
if(i%3==1) d[i].y=min(by[0],by[1]);
|
|
else d[i].y=max(by[0],by[1]);
|
|
}
|
|
init=0;
|
|
for(int i=1; i<N; i++)
|
|
{
|
|
j=i%4+1;//j搞反了
|
|
//两个都同方向才是,应该&&,错以为|| ,不是0都是真 两个小于0才是香蕉
|
|
s=same(d[i].x,d[i].y,d[j].x,d[j].y,e[0].x,e[0].y,e[1].x,e[1].y);
|
|
if(s==2)
|
|
{
|
|
init++;
|
|
}
|
|
if(s<=0)
|
|
{
|
|
if(same(e[0].x,e[0].y,e[1].x,e[1].y,d[i].x,d[i].y,d[j].x,d[j].y)<=0)
|
|
{
|
|
init=4;
|
|
break;
|
|
}
|
|
}
|
|
// printf("(%d,%d)",d[i].x,d[i].y);
|
|
}
|
|
if(init==4)
|
|
{
|
|
printf("T\n");
|
|
}
|
|
else
|
|
{
|
|
printf("F\n");
|
|
}
|
|
}
|
|
return 0;
|
|
//v[i].x=d[j].x-d[i].x;
|
|
//v[i].y=d[j].y-d[i].y;
|
|
//cr0=cross(v[i].x,v[i].y,e[0].x-d[i].x,e[0].y-d[i].y);
|
|
//cr1=cross(v[i].x,v[i].y,e[1].x-d[i].x,e[1].y-d[i].y);
|
|
//sc1=sign(cr0);
|
|
//sc2=sign(cr1);
|
|
//if(sc1<=0&&sc2<=0)
|
|
//{
|
|
// init++;
|
|
//}
|
|
}
|