QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#547#322906#7730. Convex CheckerZSH_ZSHieeFailed.2024-02-29 15:26:472024-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 CheckerieeAC ✓22ms5236kbC++17778b2024-02-07 22:38:022024-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;
}