QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279256#7730. Convex CheckerPhantomThresholdWA 0ms4152kbC++201.3kb2023-12-08 14:44:272023-12-08 14:44:29

Judging History

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

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2023-12-08 14:44:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4152kb
  • [2023-12-08 14:44:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long db;
struct point
{
	db x,y;
	point operator+(const point &p)const{return {x+p.x,y+p.y};}
	point operator-(const point &p)const{return {x-p.x,y-p.y};}
	db operator*(const point &p)const{return x*p.y-y*p.x;}
	db operator^(const point &p)const{return x*p.x+y*p.y;}
	point turn90()const{return (point){-y,x};}
	db abs2()const{return x*x+y*y;}
	bool operator<(const point &p)const{/*int pu=getP(),pv=p.getP();if(pu!=pv)return pu<=pv;*/return *this*p>0;}
	friend istream& operator>>(istream &is,point &p){is>>p.x>>p.y;return is;}
	friend ostream& operator<<(ostream &os,const point &p){os<<p.x<<' '<<p.y;return os;}
};
const double pi=acos(-1.),eps=1e-6;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<point> a(n+5);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	double turn=0.;
	for(int i=1;i<=n;i++)
	{
		turn+=atan2((a[i%n+1]-a[i])*(a[(i+1)%n+1]-a[i%n+1]),(a[i%n+1]-a[i])^(a[(i+1)%n+1]-a[i%n+1]));
	}
	if(turn<0)
	{
		turn=-turn;
		reverse(a.begin()+1,a.begin()+n+1);
	}
	if(abs(turn-2*pi)>eps)
	{
		cout<<"No\n";
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(atan2((a[i%n+1]-a[i])*(a[(i+1)%n+1]-a[i%n+1]),(a[i%n+1]-a[i])^(a[(i+1)%n+1]-a[i%n+1]))<0)
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3940kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

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

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: 3936kb

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: 3676kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

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

input:

5
1 0
4 1
0 1
2 0
3 2

output:

No

result:

ok answer is NO

Test #6:

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

input:

5
0 0
1000000000 0
1000000000 500000000
1000000000 1000000000
0 1000000000

output:

Yes

result:

wrong answer expected NO, found YES