QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#547 | #322906 | #7730. Convex Checker | ZSH_ZSH | iee | Failed. | 2024-02-29 15:26:47 | 2024-02-29 15:26:48 |
詳細信息
Extra Test:
Accepted
time: 1ms
memory: 3808kb
input:
6 1 1 4 5 1 4 1 9 1 9 8 10
output:
No
result:
ok answer is NO
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322906 | #7730. Convex Checker | iee | AC ✓ | 22ms | 5236kb | C++17 | 778b | 2024-02-07 22:38:02 | 2024-07-04 19:27:56 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ld PI = acos(-1);
using vec = complex<ll>;
#define C(p, q) imag(conj(p) * (q))
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<vec> a(n);
for (vec &v : a) {
ll x, y;
cin >> x >> y;
v = {x, y};
}
if (C(a[1] - a[0], a[2] - a[0]) < 0) reverse(a.begin(), a.end());
ld sum = 0;
for (int i = 0; i < n; i++) {
vec p = a[i], q = a[(i + 1) % n], r = a[(i + 2) % n];
if (C(q - p, r - p) <= 0) {
cout << "No" << "\n";
return 0;
}
ld ang = arg(r - q) - arg(q - p);
if (ang < 0) ang += PI * 2;
ang = PI - ang, sum += ang;
}
cout << (fabs(sum - PI * (n - 2)) < 1e-8 ? "Yes" : "No") << "\n";
return 0;
}