QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#425 | #240338 | #7730. Convex Checker | ucup-team1209 | syf0 | Success! | 2023-11-07 10:28:32 | 2023-11-07 10:28:32 |
Details
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 | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240338 | #7730. Convex Checker | syf0 | WA | 37ms | 16176kb | C++14 | 1.3kb | 2023-11-05 14:41:46 | 2023-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";
}