QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#425#240338#7730. Convex Checkerucup-team1209syf0Success!2023-11-07 10:28:322023-11-07 10:28:32

詳細信息

Extra Test:

Wrong Answer
time: 2ms
memory: 16248kb

input:

8
0 0
2 2
3 1
2 0
1 1
2 2
4 0
2 -2

output:

Yes

result:

wrong answer expected NO, found YES

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240338#7730. Convex Checkersyf0WA 37ms16176kbC++141.3kb2023-11-05 14:41:462023-11-07 10:28:44

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
const int N=2e5+5;
using namespace std;
struct point
{
	double x,y;
	point(double x=0,double y=0):x(x),y(y){}
}a[N],ans[N];
typedef point vectors;
vectors operator+(vectors a,vectors b){return vectors(a.x+b.x,a.y+b.y);}
//Vector+Vector=Vector,point+Vector=point
vectors operator-(point a,point b){return vectors(a.x-b.x,a.y-b.y);}
//point-point=Vector
vectors operator*(vectors a,double p){return vectors(a.x*p,a.y*p);}
//Vector*point=Vector
vectors operator/(vectors a,double p){return vectors(a.x/p,a.y/p);}
//Vector/dig=Vector
bool operator<(const point& a,const point& b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
//point位置
double cross(vectors a,vectors b){return a.x*b.y-a.y*b.x;}
//Vector叉积
int andrew(point* p,int n,point* cc)
{
//	sort(p+1,p+n+1);
	int s=0;
	for(int i=1;i<=n;i++)
	{while(s>1&&cross(cc[s-1]-cc[s-2],p[i]-cc[s-2])<=0)s--;cc[s++]=p[i];}
	int k=s;
	for(int i=n-1;i>=1;i--)
	{while(s>k&&cross(cc[s-1]-cc[s-2],p[i]-cc[s-2])<=0)s--;cc[s++]=p[i];}
	if(n>1)s--;
	return s;
}
int n;
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
	int len=andrew(a,n,ans);
	if(len!=n)cout<<"No\n";
	else cout<<"Yes\n";
}