QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454919 | #7730. Convex Checker | Nephrenn | WA | 20ms | 5204kb | C++20 | 1.5kb | 2024-06-25 16:40:53 | 2024-06-25 16:40:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MAXN = 1e2 + 10;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
random_device seed;
mt19937 rnd(seed());
mt19937_64 rnd_64(seed());
const double eps = 1e-8;
int sgn(double x) {
return x < -eps ? -1 : (x > eps ? 1 : 0);
}
struct Point {
ll x, y;
Point operator - (const Point &a) {
return {x - a.x, y - a.y};
}
};
ll dot(const Point &a, const Point &b) {
return a.x * b.x + a.y * b.y;
}
ll det(const Point &a, const Point &b) {
return a.x * b.y - a.y * b.x;
}
double len(const Point &a) {
return sqrt(a.x * a.x + a.y * a.y);
}
double theta(const Point &a, const Point &b) {
return acos(1.0 * dot(a, b) / len(a) / len(b));
}
void solve () {
int n;
cin >> n;
vector<Point> p(n);
double sum = 0;
for(int i = 0; i < n; ++i) cin >> p[i].x >> p[i].y;
for(int i = 0; i < n; ++i) {
int i1 = i, i2 = (i + 1) % n, i3 = (i + 2) % n;
Point v1 = p[i2] - p[i1], v2 = p[i3] - p[i2];
if(sgn(det(v1, v2)) == 0) {
cout << "No\n";
return;
}
sum += theta(v1, v2);
}
if(sgn(sum - 2 * acos(-1)) <= 0) cout << "Yes\n";
else cout << "No\n";
}
int main () {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int Task = 1;
while (Task--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3912kb
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: 3760kb
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: 3580kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 0ms
memory: 3844kb
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: 0ms
memory: 3612kb
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: 0ms
memory: 3720kb
input:
5 0 0 1000000000 0 1000000000 499999999 1000000000 1000000000 0 1000000000
output:
No
result:
ok answer is NO
Test #8:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
5 0 0 999999999 0 1000000000 50000000 999999999 1000000000 0 1000000000
output:
Yes
result:
ok answer is YES
Test #9:
score: 0
Accepted
time: 20ms
memory: 5204kb
input:
128312 5578014 410408218 5585076 410404717 5588011 410403262 5588473 410403033 5589740 410402405 5593295 410400643 5593751 410400417 5597248 410398684 5598935 410397848 5600618 410397014 5605185 410394751 5610514 410392111 5614281 410390245 5617263 410388768 5621142 410386847 5630840 410382045 56310...
output:
Yes
result:
ok answer is YES
Test #10:
score: -100
Wrong Answer
time: 17ms
memory: 5136kb
input:
128086 149550602 509469827 149551059 509465022 149551336 509462107 149551964 509455497 149552572 509449094 149553350 509440895 149553656 509437667 149554161 509432339 149554254 509431357 149554545 509428284 149555017 509423299 149555366 509419611 149555842 509414580 149556382 509408867 149556564 509...
output:
No
result:
wrong answer expected YES, found NO