QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346425 | #7730. Convex Checker | tz3528 | WA | 1ms | 3916kb | C++20 | 1.6kb | 2024-03-08 14:59:36 | 2024-03-08 14:59:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
//结构定义
//向量、点结构
struct point{
double x,y;
int judge;
/*
判断返回类型
j==0 无解
j==1 有解
*/
};
//以x升序排列,其次以y升序排列
bool sortXupYup(point u,point v){
if(u.x!=v.x) return u.x<v.x;
else return u.y<v.y;
}
//二阶行列式
double det(double a1, double a2, double b1, double b2){return a1*b2-a2*b1;}
//向量运算
//向量、点的加操作
point operator+(point u,point v){return {u.x+v.x,u.y+v.y,1};}
//向量、点的减操作
point operator-(point u,point v){return {u.x-v.x,u.y-v.y,1};}
//向量的乘操作
point operator*(point u,double k){return {u.x*k,u.y*k,1};}
//向量的除操作
point operator/(point u,double k){return {u.x/k,u.y/k,1};}
//叉积运算
double operator^(point u,point v){return u.x*v.y-v.x*u.y;}
//点乘运算
double operator*(point u,point v){return u.x*v.x+u.y*v.y;}
//向量v在向量u的方向
int orderVector(point u,point v){
double p=(u^v);
/*
1表示v在u的逆时针方向
0表示二者同向或反向
-1表示v在u的顺时针方向
*/
if(p>0) return 1;
else if(p==0.0) return 0;
else return -1;
}
int main(){
int n,m;
cin>>n;
point u[n+10],v[n+10];
for(int i=1;i<=n;i++){
cin>>u[i].x>>u[i].y;
}
int ans1=1,ans2=1;
for(int i=1;i<=n;i++){
v[i]=u[i%n+1]-u[i];
}
for(int i=1;i<=n;i++){
if(orderVector(v[i%n+1],v[i])<=0) ans1=0;
if(orderVector(v[i%n+1],v[i])>=0) ans2=0;
}
if(ans1||ans2) printf("Yes\n");
else printf("No\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 3856kb
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: 3872kb
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: 3812kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3916kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
Yes
result:
wrong answer expected NO, found YES