题意:平面上有n个红点和m个蓝点,是否存在一条直线使得任取一个红点和一个蓝点都在直线的异侧?这条直线不能穿过红点或蓝点
分析:显然,求红点凸包和蓝点凸包,如果这两个凸包有相交的部分就不存在这样的直线,否则就存在呗
#includeusing namespace std;double eps=1e-15;double pi=acos(-1);struct Point{ double x,y; Point(double x=0,double y=0):x(x),y(y){}};typedef Point Vector;Vector operator + (Vector A,Vector B){ return Vector(A.x+B.x,A.y+B.y);}Vector operator - (Vector A,Vector B){ return Vector(A.x-B.x,A.y-B.y);}Vector operator * (Vector A,double B){ return Vector(A.x*B,A.y*B);}Vector operator / (Vector A,double B){ return Vector(A.x/B,A.y/B);}int dcmp(double x){ if(fabs(x) 1&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--; ch[m++]=p[i]; } int k=m; for(int i=n-2;i>=0;i--){ while(m>k&&Cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0)m--; ch[m++]=p[i]; } if(n>1)m--; return m;}void readp(Point &A){ scanf("%lf%lf",&A.x,&A.y);}bool onsegment(Point p,Point a1,Point a2){ if(p==a1||p==a2)return false; return dcmp(Cross(a1-p,a2-p))==0&&dcmp(Dot(a1-p,a2-p))<0;}bool segmentcross(Point a1,Point a2,Point b1,Point b2){ if(a1==b1||a1==b2||a2==b1||a2==b2)return true; double c1=Cross(a2-a1,b1-a1),c2=Cross(a2-a1,b2-a1), c3=Cross(b2-b1,a1-b1),c4=Cross(b2-b1,a2-b1); return dcmp(c1)*dcmp(c2)<0&&dcmp(c3)*dcmp(c4)<0;}int intubao(Point *ch,int n,Point p){ Vector A,B; int flag=0; for(int i=0;i 0){ flag++; } } if(flag==-1||flag==n)return 1; return 0;}int T,n,m;Point p1[10005],ch1[10005],p2[10005],ch2[10005];int main(){ while(~scanf("%d%d",&n,&m)&&!(n==0&&m==0)){ for(int i=0;i