QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#596702 | #9434. Italian Cuisine | ucup-team918# | WA | 0ms | 3972kb | C++14 | 2.2kb | 2024-09-28 16:18:39 | 2024-09-28 16:18:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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 ld eps = 1e-15;
bool equal(ld x, ld y) { return fabs(x - y) < eps; }
int n;
struct point {
ld x, y;
} p[N];
struct cir {
point o;
ld r;
} c;
struct line {
ld k, b;
ld gety(ld x) {
return k * x + b;
}
};
ld area(point u, point v, point w) {
ld X1 = v.x - u.x, Y1 = v.y - u.y;
ld X2 = w.x - u.x, Y2 = w.y - u.y;
ld S = fabs(X1 * Y2 - Y1 * X2);
return S;
}
ld 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 = -(ld)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) {
ld S = area(u, v, w);
ld S1 = area(u, v, o);
ld S2 = area(u, w, o);
ld 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;
ld 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 l = getline(p[L], p[G]);
if (c.r * sqrt(l.k * l.k + 1.0) - fabs(l.k * c.o.x - c.o.y + l.b) > 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: 3972kb
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: 3864kb
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'