QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596633#9434. Italian Cuisineucup-team918#WA 0ms3912kbC++142.5kb2024-09-28 16:09:212024-09-28 16:09:22

Judging History

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

  • [2024-09-28 16:09:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3912kb
  • [2024-09-28 16:09:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

template<typename T> inline void read(T &s) {
	char c = getchar(); int f = 1; s = 0;
	while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }
	while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
	if (f < 0) s = -s;
}

const int N = 1e5 + 5;
const double eps = 1e-9;

bool equal(double x, double y) { return fabs(x - y) < eps; }

int n;
struct point {
	double x, y;
} p[N];
struct cir {
	point o;
	double r;
} c;
struct line {
	double k, b;
	double gety(double x) {
		return k * x + b;
	}
};

double area(point u, point v, point w) {
	double X1 = v.x - u.x, Y1 = v.y - u.y;
	double X2 = w.x - u.x, Y2 = w.y - u.y;
	double S = fabs(X1 * Y2 - Y1 * X2);
	return S;
}
double dist(point u, point v) {
	return sqrt((u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y));
}
double dist(point u, line l) {
	return fabs(l.k * u.x - u.y + l.b) / sqrt(l.k * l.k + 1.0);
}
point intersect(line u, line v) {
	point w;
	w.x = (v.b - u.b) / (u.k - v.k);
	w.y = u.gety(w.x);
	return w;
}
line vertical(line l, point u) {
	line v;
	v.k = -(double)1.0 / l.k;
	v.b = u.y - u.x * v.k;
	return v;
}
line getline(point u, point v) {
	line l;
	l.k = (v.y - u.y) / (v.x - u.x);
	l.b = u.y - l.k * u.x;
	return l;
}
bool intri(point u, point v, point w, point o) {
	double S = area(u, v, w);
	double S1 = area(u, v, o);
	double S2 = area(u, w, o);
	double S3 = area(v, w, o);
	return equal(S, S1 + S2 + S3);
}

ll ans;

void init() {
	ans = 0;
}
int nxt(int id) {
	++id;
	if (id > n) id -= n;
	return id;
}
void solve() {
	init();
	scanf("%d", &n);
	scanf("%lf%lf%lf", &c.o.x, &c.o.y, &c.r);
	for (int i = 1; i <= n; ++i) scanf("%lf%lf", &p[i].x, &p[i].y);
	if (n == 3) { puts("0"); return ; }
	int L = 1, R = 1;
	double now = 0;
	for (L = 1; L <= n; ++L) {
		if (L == R) R = nxt(R);
		while (true) {
			int G = nxt(R);
			if (nxt(G) == L) break;
			if (intri(p[L], p[R], p[G], c.o)) break;

			// line l1 = getline(p[L], p[G]);
			// line l2 = vertical(l1, c.o);
			// point o = intersect(l1, l2);
			// if (c.r - dist(c.o, o) > eps) break;

			line l1 = getline(p[L], p[G]);
			if (c.r - dist(c.o, l1) > eps) break;

			now += area(p[L], p[R], p[G]);
			ans = max(ans, (ll)(now + 0.5));
			R = G;
		}
		if (R != nxt(L))
			now -= area(p[L], p[nxt(L)], p[R]);
	}
	printf("%lld\n", ans);
}

int main() {
	int T; read(T);
	while (T--) solve();
	return 0;
}

详细

Test #1:

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

input:

3
5
1 1 1
0 0
1 0
5 0
3 3
0 5
6
2 4 1
2 0
4 0
6 3
4 6
2 6
0 3
4
3 3 1
3 0
6 3
3 6
0 3

output:

5
24
0

result:

ok 3 number(s): "5 24 0"

Test #2:

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

input:

1
6
0 0 499999993
197878055 -535013568
696616963 -535013568
696616963 40162440
696616963 499999993
-499999993 499999993
-499999993 -535013568

output:

286862654137719264

result:

wrong answer 1st numbers differ - expected: '0', found: '286862654137719264'