题意:没看懂题意,在DISCUSS找到的,,判断一个凸包,且每两个凸点间的直线上有一个点。。
思路:找两个凸包一个包括非顶点的边点,另一个不包含,比较一下两个凸包。。
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <stack> using namespace std; struct cpoint{ double x,y; bool operator<(const cpoint a)const{ return y<a.y||(y==a.y&&x<a.x); } bool operator==(const cpoint a)const{ return a.x==x&&a.y==y; } void get(){scanf("%lf%lf",&x,&y);} }; double x_mult(cpoint a,cpoint b,cpoint c){ return (a.x-c.x)*(b.y-c.y)-(a.y-c.y)*(b.x-c.x); } cpoint p[1009],ans1[1009],ans2[1009]; int granham(cpoint p[],int s,cpoint r[],double EPS) { int i,len,top = 1; sort(p,p+s); r[0] = p[0],r[1] = p[1]; if(s<3) return s; for(i=2;i<s;i++){ while(top&&x_mult(p[i],r[top],r[top-1])>EPS) top--; r[++top] = p[i]; } len = top;r[++top] = p[s-2]; for(i=s-3;i>=0;i--){ while(top!=len&&x_mult(p[i],r[top],r[top-1])>EPS) top--; r[++top] = p[i]; } return top; } int main() { freopen("in.txt","r",stdin); int cas,n; scanf("%d",&cas); while(cas--) { scanf("%d",&n); for(int i=0;i<n;i++) p[i].get(); if(n<=5){ printf("NO\n");continue; } int k1=granham(p,n,ans1,1e-6); int k2=granham(p,n,ans2,-1e-6); int k = 1;bool fin = false; for(int i=1;i<=k1;i++) if(ans1[i]==ans2[k]){ if(ans1[i-1]==ans2[k-1]) fin = true; else k++; } if(fin) printf("NO\n"); else printf("YES\n"); } return 0; }