QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#406152 | #7730. Convex Checker | RainningLove | WA | 1ms | 3772kb | C++20 | 1.5kb | 2024-05-06 21:16:13 | 2024-05-06 21:16:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct Point {
long double x,y;
friend bool operator<(Point a,Point b) {
if(a.x==b.x)return a.y<b.y;
return a.x<b.x;
}
Point(long long x,long long y) {
this->x=x;
this->y=y;
}
};
struct Line {
long double A,B,C;
Line(Point a,Point b) {
this->A = b.y-a.y;
this->B = a.x-b.x;
this->C = a.y*b.x - a.x*b.y;
}
int contains(Point x) {
if(A*x.x + B*x.y+C==0) return 1;
return 0;
}
};
struct Vector {
long long x,y;
Vector(Point a,Point b) {
this->x=b.x-a.x;
this->y=b.y-a.y;
}
};
int n;
vector<Point> a;
void solve() {
cin>>n;
set<Point> st;
for(int i=1;i<=n;i++) {
long long x,y;
cin>>x>>y;
a.push_back(Point(x,y));
}
for(int i=0;i<n;i++) a.push_back(a[i]),st.insert(a[i]);
if(st.size()!=n) return(void)(cout<<"No");
int f=1;
for(int i=1;i<=n;i++) {
Vector x(a[i-1],a[i]),y(a[i],a[i+1]);
if(x.x*y.y-x.y*y.x<=0) f=0;
}
if(f) return (void)(cout<<"Yes");
f=1;
for(int i=1;i<=n;i++) {
Vector x(a[i-1],a[i]),y(a[i],a[i+1]);
if(x.x*y.y-x.y*y.x>=0) f=0;
}
if(f) return (void)(cout<<"Yes");
cout<<"No";
}
/*
(1,0)
(0,1)
a.x*b.y-a.y*b.x>0 a在b右侧
*/
int main() {
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--)
solve();
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 3772kb
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: 3532kb
input:
4 0 0 0 3 1 2 1 1
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3528kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
Yes
result:
wrong answer expected NO, found YES