poj3304

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define dd double
#define maxn 300
int T;
int n;
structP{
   dd x,y;	
}a[maxn];
bool ling(dd x){
	if(x>-eps&&x<eps)return 1;
	return 0;
}
bool p;
dd mul(P a,P b,P c){
	return (a.x-b.x)*(c.y-b.y)-(c.x-b.x)*(a.y-b.y);
}
P make(dd x,dd y){
 P ans;
 ans.x=x;
 ans.y=y;
 return ans;	
}
int main(){
//	cout<<mul(make(0,1),make(1,1),make(1,2));
	scanf("%d",&T);
	while(T--){
	   scanf("%d",&n);
	   for(int i=1;i<=n;i++){
		   scanf("%lf%lf%lf%lf",&a[i*2-2].x,&a[i*2-2].y,&a[i*2-1].x,&a[i*2-1].y);	
   	   }
	   	for(int i=0;i<(n<<1);i++){
			for(int j=i+1;j<(n<<1);j++)if(a[i].x!=a[j].x||a[i].y!=a[j].y){
				p=0;
				for(int k=1;k<=n;k++){
				   dd r1,r2;
				   r1=mul(a[i],a[j],a[(k<<1)-2]);
				   r2=mul(a[i],a[j],a[(k<<1)-1]);
				   if(ling(r1)||ling(r2))continue;	
				   if(r1<0&&r2>0)continue;
				   if(r1>0&&r2<0)continue;
				   p=1;
				}
				if(!p){
				//	cout<<i<<" "<<j<<endl;
				  printf("Yes!\n");
				  goto loop;	
				}
			}			
		}
		printf("No!\n");
		loop:;
	}
}
posted @ 2014-02-03 18:46  wangyucheng  阅读(151)  评论(0编辑  收藏  举报