The meaning of problems: Given n points, these points constituting the convex hull is determined, and then counterclockwise output, in addition to the q-th query, asking whether a point on each bag convex.
Solution: two-dimensional convex hull bare title, whether directly point to determine the cross product, the time complexity of n2 in the convex hull, I do not know why this question to the 15s, and then I ran the code just 15ms
#include <bits/stdc++.h> using 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)<eps)return 0; else return x<0?-1:1; } bool operator < (const Point &a,const Point &b){ return dcmp(a.x-b.x)<0||(dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)<0); } bool operator == (const Point &a,const Point &b){ return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0; } double Cross(Vector A,Vector B){ return A.x*B.y-A.y*B.x; } double Dot(Vector A,Vector B){ return A.x*B.x+A.y*B.y; } Vector Rotate(Vector A,double rad){ return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad)); } int tubao (Point * P, int n-, Point * CH) { // find the convex hull, returns the convex hull length of the array Sort (P, P + n-); int m = 0 ; for ( int I = 0 ; I <n- ; I ++ ) { the while (m> . 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 (CH Point *, int n-, Point p) { // determines whether a point p within the convex hull of the Vector A, B; int In Flag = 0 ; for ( int I = 0 ; I <n-; I ++ ) { A=ch[(i+1)%n]-ch[i]; B = p- CH [I]; / * IF (onsegment (P, CH [I], CH [(I +. 1) n-%])) {// This is regarded as the point in question the said projections on the convex hull the outer package flag=-1; break; }*/ if(Cross(A,B)>0){ flag++; } } if(flag==-1||flag==n)return 1; return 0; } int T,n,q,m; Point p1[10005],ch1[10005]; struct node{ double x,y; }g[1005]; int main(){ scanf("%d",&T); int kase=0; while(T--){ scanf("%d%d",&n,&q); for(int i=0;i<n;i++){ readp(p1[i]); } int m1=tubao(p1,n,ch1); for(int i=1;i<=q;i++){ scanf("%lf%lf",&g[i].x,&g[i].y); } printf("Case %d\n",++kase); for(int i=0;i<m1;i++){ printf("%d %d\n",(int)ch1[i].x,(int)ch1[i].y); } printf("%d %d\n",(int)ch1[0].x,(int)ch1[0].y); for(int i=1;i<=q;i++){ Point t; t.x=g[i].x; t.y=g[i].y; printf("%d %d ",(int)t.x,(int)t.y); if(intubao(ch1,m1,t))printf("is unsafe!\n"); else printf("is safe!\n"); } printf("\n"); } }