QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#494 | #279253 | #7730. Convex Checker | PhantomThreshold | PhantomThreshold | Failed. | 2023-12-08 14:43:55 | 2023-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 Checker | PhantomThreshold | AC ✓ | 22ms | 5388kb | C++20 | 1.3kb | 2023-12-08 14:43:32 | 2024-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;
}