QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#474341#7730. Convex CheckerAAAAAZBXWA 0ms4112kbC++142.6kb2024-07-12 17:31:192024-07-12 17:31:19

Judging History

你现在查看的是最新测评结果

  • [2024-07-12 17:31:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4112kb
  • [2024-07-12 17:31:19]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define x first
#define y second
#define endl '\n'
const double eps = 1e-6;
const double INF = 2e9;
const long double PI = acos(-1);
const int N = 200010;
using namespace std;
typedef pair<int, int>PII;
typedef pair<double, double> PDD;//????????
struct Circle {//?????
	PDD c;//??
	double r;//??
	Circle() {}
	Circle(PDD _c, double _r) :c(_c), r(_r) {}
};
PDD p1, p2, p0, p3;
//PDD q[N], p[N], temp[N];
double ans;
int n;
bool used[N];
int stk[N], top;
PDD p[200010];
//??????
int dcmp(double a, double b) {
	if (fabs(a - b) < eps)return 0;
	else if (a < b)return 1;
	return -1;
}

//????
int sign(double a) {
	if (fabs(a) < eps)return 0;
	else if (a < 0)return -1;
	return 1;
}

//????????
PDD operator- (PDD a, PDD b) { return { a.x - b.x,a.y - b.y }; }
PDD operator+ (PDD a, PDD b) { return { a.x + b.x,a.y + b.y }; }
PDD operator* (PDD a, double b) { return { a.x * b,a.y * b }; }
PDD operator/ (PDD a, double b) { return { a.x / b,a.y / b }; }

//??
double operator* (PDD a, PDD b) { return a.x * b.y - a.y * b.x; }
//??
double operator& (PDD a, PDD b) { return a.x * b.x + a.y * b.y; }

//??????????????????norm????????????
double get_len(PDD a) { return sqrt(a & a); }

//???????
double get_dis(PDD a, PDD b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }

//??????????????????2?
double area(PDD a, PDD b, PDD c) { return (b - a) * (c - a); }

//?p???ab???
double distance_to_line(PDD p, PDD a, PDD b) {
	PDD v1 = b - a, v2 = p - a;
	return fabs((v1 * v2) / get_len(v1));
}

//?a?????b????
PDD rotate(PDD a, double b) { return{ a.x * cos(b) + a.y * sin(b),-a.x * sin(b) + a.y * cos(b) }; }

//????
PDD get_line_intersection(PDD p, PDD v, PDD q, PDD w) {
	PDD u = p - q;
	double t = (w * u) / (v * w);
	return p + v * t;
}

//??ac??ab??????/?????/??/??
int check(PDD a, PDD b, PDD c) {
	PDD p = b - a, q = c - a;
	if (sign(p * q))return sign(p * q);
	else if (sign(p & q) == -1)return -1;
	else if (get_len(q) > get_len(q))return 1;
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &p[i].x, &p[i].y);
	}
	long double sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] == p[(i + 1) % n]) {
			puts("No");
			return 0;
		}
		if (sign(area(p[i], p[(i + 1) % n], p[(i + 2) % n])) != sign(area(p[(i + 1) % n], p[(i + 2) % n], p[(i + 3) % n]))) {
			puts("No");
			return 0;
		}
		auto u = p[i] - p[(i + 1) % n], v = p[(i + 2) % n] - p[(i + 1) % n];
		long double t = atan2(u.y, u.x) - atan2(v.y, v.x);
		if (t < 0)t += PI * 2;
		sum += t;
	}
	if (fabs(sum - (n - 2) * PI) < eps)
		puts("Yes");
	else puts("No");
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4112kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3984kb

input:

4
0 0
0 1
1 1
1 0

output:

No

result:

wrong answer expected YES, found NO