QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#494#279253#7730. Convex CheckerPhantomThresholdPhantomThresholdFailed.2023-12-08 14:43:552023-12-08 14:43:56

详细

Extra Test:

Accepted
time: 0ms
memory: 3976kb

input:

3
-1000000000 -1000000000
1000000000 1000000000
-1000000000 -999999999

output:

Yes

result:

ok answer is YES

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#279253#7730. Convex CheckerPhantomThresholdAC ✓22ms5388kbC++201.3kb2023-12-08 14:43:322024-07-04 19:27:19

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