#include <stdio.h>
#include <stdlib.h>
int jiao(long long x1,long long y1,long long x2,long long y2,long long x3,long long y3,long long x4,long long y4)
{
long long a,b,c,d;
a=(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);//ab*ac,ad*ab,ac*ad,bd*bc
b=(x4-x1)*(y2-y1)-(x2-x1)*(y4-y1);
c=(x3-x1)*(y4-y1)-(x4-x1)*(y3-y1);//少了c和d这个判断orz
d=(x4-x2)*(y3-y2)-(y4-y2)*(x3-x2);
//printf("%lld %lld %lld %lld %lld %lld %lld %lld\n",x1,y1,x2,y2,x3,y3,x4,y4);
if(a*b>=0&&c*d>=0)return 1;
else return 0;
}
int main()
{
int n,k[50],i,j,u,v;
long long x[50][110],y[50][110];
while(~scanf("%d",&n)){
for(i=0;i<=n-1;i++){
scanf("%d",&k[i]);
for(j=0;j<=k[i]-1;j++){
scanf("%lld%lld",&x[i][j],&y[i][j]);
}
}
if(n==1){
printf("No\n");
continue;
}
int flag=0;
for(i=0;i<n-1;i++){
for(j=i+1;j<=n-1;j++){
for(u=0;u<k[i]-1;u++){
for(v=0;v<k[j]-1;v++){
if(jiao(x[i][u],y[i][u],x[i][u+1],y[i][u+1],x[j][v],y[j][v],x[j][v+1],y[j][v+1]))
{
flag=1;
break;
}
}
if(flag==1)break;
}
if(flag==1)break;
}
if(flag==1)break;
}
if(flag==1)printf("Yes\n");
else printf("No\n");
}
return 0;
}
之前没考虑到第三种情况,然后wa了好几次
ACXAD*BDXBC>0并且ABXAC*ADXAB>0则有相交