QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#313199 | #7730. Convex Checker | unclezhou | WA | 1ms | 4124kb | C++14 | 1.1kb | 2024-01-24 16:33:42 | 2024-01-24 16:33:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef double DB;
const int N=2e5+10;
int n;
struct point{
DB x,y;
point operator + (const point &a) const{
return {x+a.x,y+a.y};
}
point operator - (const point &a) const{
return {x-a.x,y-a.y};
}
point operator * (DB a) const{
return {x*a,y*a};
}
};
struct line{
point s,t;
};
DB dot (const point &a,const point &b){
return a.x*b.x+a.y*b.y;
}
DB det (const point &a,const point &b){
return a.x*b.y-a.y*b.x;
}
DB sqr(DB a){
return a*a;
}
DB dis (const point &a){
return (sqrt(sqr(a.x)+sqr(a.y)));
}
point a[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].x>>a[i].y;
}
DB t=0;
a[1+n]=a[1];
a[2+n]=a[2];
for(int i=1;i<=n;i++){
//line u,v;
point u=a[i+1]-a[i];
point v=a[i+2]-a[i+1];
if(det(u,v)==0){
cout<<"No\n";
return 0;
}
t+=(acos(dot(u,v)/dis(u)/dis(v)));
}
if(t==2*acos(-1)){
cout<<"Yes\n";
}
else cout<<"No\n";
//cout<<t<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4060kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 4032kb
input:
4 0 0 0 1 1 1 1 0
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 1ms
memory: 4124kb
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: 3736kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 0ms
memory: 4104kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
No
result:
ok answer is NO
Test #6:
score: 0
Accepted
time: 1ms
memory: 4060kb
input:
5 0 0 1000000000 0 1000000000 500000000 1000000000 1000000000 0 1000000000
output:
No
result:
ok answer is NO
Test #7:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
5 0 0 1000000000 0 1000000000 499999999 1000000000 1000000000 0 1000000000
output:
No
result:
ok answer is NO
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 4000kb
input:
5 0 0 999999999 0 1000000000 50000000 999999999 1000000000 0 1000000000
output:
No
result:
wrong answer expected YES, found NO