QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#595179 | #9434. Italian Cuisine | ucup-team2112# | WA | 0ms | 3616kb | C++20 | 2.6kb | 2024-09-28 12:53:26 | 2024-09-28 12:53:28 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
typedef struct P {
i64 x, y;
P(i64 x = 0, i64 y = 0) : x(x), y(y) {}
P operator+(P r) { return P(x + r.x, y + r.y); }
P operator-(P r) { return P(x - r.x, y - r.y); }
P operator*(i64 r) { return P(x * r, y * r); }
P operator/(i64 r) { return P(x / r, y / r); }
bool operator<(const P &r) const { return x < r.x || (x == r.x && y < r.y); }
bool operator==(const P &r) const { return x - r.x == 0 && y - r.y == 0; }
bool upper() { return y > 0 || (y == 0 && x > 0); }
}V;
i64 Dot(V A, V B) { return A.x*B.x + A.y*B.y; }
i64 Cross(V A, V B) { return A.x*B.y - A.y*B.x; }
i64 Length(V A) { return Dot(A, A); }
struct Circle {
P c;
i64 r;
Circle(){}
Circle(P c, i64 r) : c(c), r(r) {}
};
struct Line {
P p;
V v;
Line(){}
Line(P p, V v): p(p), v(v){}
};
int GetLineCircleIntersecion(Line L, Circle C) {
i64 a = L.v.x, b = L.p.x - C.c.x, c = L.v.y, d = L.p.y - C.c.y;
i64 e = a*a + c*c, f = 2*(a*b + c*d), g = b*b + d*d - C.r*C.r;
i64 delta = f*f - 4*e*g;
if(delta < 0) return 0; //相离
if(delta == 0) { //相切
return 1;
}
return 2;
}
using i128 = __int128;
void solve(){
int n;
std::cin >> n;
Circle c;
std::cin >> c.c.x >> c.c.y >> c.r;
std::vector<P> p(n);
for (auto &[x, y] : p) {
std::cin >> x >> y;
}
for (int i = 0; i <= n; i += 1) {
p.emplace_back(p[i]);
}
i64 res = 0;
std::vector<i128> sum(2 * n + 1);
for (int i = 1; i <= 2 * n; i += 1) {
sum[i] = sum[i - 1] + Cross(p[i - 1] - p[0], p[i] - p[0]);
}
for (int i = 1; i <= n; i += 1) {
int lo = 1, hi = n - 1, ans = n - 1;
P a = p[i];
while(hi >= lo) {
int mid = lo + hi >> 1;
P b = p[i + mid - 1];
if (Cross(b - a, c.c - a) < 0) {
hi = mid - 1;
continue;
}
if (GetLineCircleIntersecion(Line(a, b - a), c) <= 1) {
lo = mid + 1;
ans = mid;
}
else hi = mid - 1;
}
// std::cerr << i << " " << i + ans - 1 << "\n";
i64 area = 0;
area = sum[i + ans - 1] - sum[i];
area -= Cross(p[i] - p[0], p[i + ans - 1] - p[0]);
res = std::max(res, area);
}
std::cout << res << "\n";
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
while(T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3504kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
550249412925348668
result:
wrong answer 1st numbers differ - expected: '0', found: '550249412925348668'