QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#596526 | #9434. Italian Cuisine | ucup-team918# | WA | 19ms | 3964kb | C++14 | 2.5kb | 2024-09-28 15:57:46 | 2024-09-28 15:57:48 |
Judging History
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));
}
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;
now += area(p[L], p[R], p[G]);
// printf("add (%d, %d, %d)\n", L, R, G);
// printf("area(%d, %d, %d) = %.0lf\n", L, R, G, area(p[L], p[R], p[G]));
ans = max(ans, (ll)(now + 0.5));
R = G;
// printf("L = %d, R = %d, now = %.5lf\n", L, R, now);
}
if (R != nxt(L))
now -= area(p[L], p[nxt(L)], p[R])/*, printf("del (%d, %d, %d)\n", L, nxt(L), R)*/;
}
printf("%lld\n", ans);
}
int main() {
int T; read(T);
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3896kb
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: 0
Accepted
time: 0ms
memory: 3896kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 19ms
memory: 3964kb
input:
6666 19 -142 -128 26 -172 -74 -188 -86 -199 -157 -200 -172 -199 -186 -195 -200 -175 -197 -161 -188 -144 -177 -127 -162 -107 -144 -90 -126 -87 -116 -86 -104 -89 -97 -108 -86 -125 -80 -142 -74 -162 -72 16 -161 -161 17 -165 -190 -157 -196 -154 -197 -144 -200 -132 -200 -128 -191 -120 -172 -123 -163 -138...
output:
5093 3086 2539 1546 3535 7421 4883 5711 5624 1034 2479 3920 4372 2044 4996 5070 2251 4382 4175 1489 1154 3231 4038 1631 5086 14444 1692 6066 687 1671 4849 5456 2757 8341 8557 8235 1013 5203 10853 6375 6300 4480 2303 3598 1739 2187 3385 4266 6322 909 4334 1518 948 5036 1449 2376 3180 4810 1976 1786 4...
result:
wrong answer 4th numbers differ - expected: '668', found: '1546'