QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#240302#7730. Convex Checkersyf0WA 4ms16324kbC++141.3kb2023-11-05 14:24:092023-11-05 14:24:10

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2023-11-05 14:24:10]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:16324kb
  • [2023-11-05 14:24:09]
  • 提交

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";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 16260kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 4ms
memory: 16324kb

input:

4
0 0
0 1
1 1
1 0

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 0ms
memory: 16252kb

input:

4
0 0
0 3
1 2
1 1

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 0ms
memory: 16176kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 16184kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

Yes

result:

wrong answer expected NO, found YES