QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#331002 | #7730. Convex Checker | Hanghang | WA | 0ms | 3740kb | C++14 | 725b | 2024-02-17 21:59:14 | 2024-02-17 21:59:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dcmp(ll x){return x>0?1:x<0?-1:0;}
struct Point{ll x,y;};
typedef Point Vec;
Vec operator +(Vec a,Vec b){return {a.x+b.x,a.y+b.y};}
Vec operator -(Vec a,Vec b){return {a.x-b.x,a.y-b.y};}
ll Cro(Vec a,Vec b){return a.x*b.y-a.y*b.x;}
ll Dot(Vec a,Vec b){return a.x*b.x+a.y*b.y;}
bool PolyShape(Point *p,int n)
{
p[0]=p[n];p[n+1]=p[1];
for(int i=1,op=0;i<=n;i++)
{
int o=dcmp(Cro(p[i]-p[i-1],p[i+1]-p[i]));
if(!o)return 0;
if(!op)op=o;
else if(op!=o)return 0;
}
return 1;
}
const int N=1e6+3;
int n;
Point p[N];
int main()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y;
puts(PolyShape(p,n)?"Yes":"No");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3660kb
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: 3624kb
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: 3740kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3736kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
Yes
result:
wrong answer expected NO, found YES