看了题目意思之后感觉哇,简单的 一批不就是判断线段之间有没有至少一个点嘛,,,,,结果wa到自闭,,
这个题的点有首先要根据点构造凸包,因为题目给的数据不一定是一个凸包,其次,我们在构造凸包极角排序的时候当点与左下角的点的角度大于90度的时候会把距离近的点排在前面,所以要改写极角排序的算法,,然后遍历每个点判断就行了,,多个点共线输出no,,然后傻逼的自己wa了一个晚上在于凸包都写不对,,哭
bool cmp(Point a,Point b)
{
int ans=sgn((a-p[0])^(b-p[0]));
if(ans==1)
return true;
else if(ans==0)
{
if(sgn(atan2(a.y,a.x)-PI/2)>=0)
return dist(a,p[0])>dist(b,p[0]);
else
return dist(a,p[0])<dist(b,p[0]);
}
else
return false;
}
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-8;
const int maxn=40005;
const double PI=acos(-1.0);
int sgn(double x)
{
if(fabs(x)<eps)
return 0;
if(x<0)
return -1;
else
return 1;
}
struct Point
{
double x,y;
Point(){}
Point(double _x,double _y)
{
x=_x;
y=_y;
}
Point operator -(const Point &b)const
{
return Point(x-b.x,y-b.y);
}
double operator ^(const Point &b)const
{
return x*b.y-y*b.x;
}
double operator *(const Point &b)const
{
return x*b.x+y*b.y;
}
};
Point p[maxn];
int Stack[maxn];
int top=0;
int m;
double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
}
bool cmp(Point a,Point b)
{
int ans=sgn((a-p[0])^(b-p[0]));
if(ans==1)
return true;
else if(ans==0)
{
if(sgn(atan2(a.y,a.x)-PI/2)>=0)
return dist(a,p[0])>dist(b,p[0]);
else
return dist(a,p[0])<dist(b,p[0]);
}
else
return false;
}
void graham()
{
for(int i=0;i<m;i++)
{
if(p[i].y<p[0].y||(p[i].y==p[0].y&&p[i].x<p[0].x))
swap(p[0],p[i]);
}
sort(p+1,p+m,cmp);
if(m==1)
{
Stack[0]=0;
top=0;
}
else if(m==2)
{
Stack[0]=0;
Stack[1]=1;
top=1;
}
else
{
Stack[0]=0;
Stack[1]=1;
top=1;
for(int i=2;i<m;i++)
{
while(top>0&&((p[Stack[top]]-p[Stack[top-1]])^(p[i]-p[Stack[top-1]]))<0)
top--;
top++;
Stack[top]=i;
}
}
}
bool vjudge()
{
int cont=0;
for(int i=1;i<=top;i++)
{
if(((p[Stack[i-1]]-p[Stack[i]])^(p[Stack[(i+1)%(top+1)]]-p[Stack[i]]))!=0)
{
cont++;
}
}
if(cont==0)
return false;
cont=0;
for(int i=1;i<=top;i++)
{
if(((p[Stack[i-1]]-p[Stack[i]])^(p[Stack[(i+1)%(top+1)]]-p[Stack[i]]))!=0)
{
if(cont==0)
return false;
cont=0;
}
else
cont++;
/*if(i==top)
{
if(cont==0)
return false;
}*/
}
return true;
}
int main()
{
int n;
cin>>n;
while(n--)
{
cin>>m;
for(int i=0;i<m;i++)
cin>>p[i].x>>p[i].y;
if(m<6)
{
cout<<"NO"<<endl;
continue;
}
graham();
/*for(int i=0;i<=top;i++)
{
cout<<p[Stack[i]].x<<" "<<p[Stack[i]].y<<endl;
}*/
if(vjudge()==true)
{
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
}
return 0;
}