QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#595672 | #9434. Italian Cuisine | ucup-team3548# | WA | 0ms | 3804kb | C++17 | 1.9kb | 2024-09-28 14:13:24 | 2024-09-28 14:13:24 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include <vector>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
using ld = long double;
struct Point {
ll x, y;
void read() {
scanf("%lld %lld", &x, &y);
}
Point() {}
Point(Point a, Point b) {
x = b.x - a.x;
y = b.y - a.y;
}
};
using Vec = Point;
ll cha(Vec a, Vec b) {
return a.x * b.y - b.x * a.y;
}
ld dis(Point a, Point b) {
ld dx = a.x - b.x;
ld dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
void solve() {
int n;
scanf("%d", &n);
ll r; // radius
Point pina;
pina.read();
scanf("%lld", &r);
auto jiao = [&](Point a, Point b) -> bool {
ll area = cha(Vec(a, b), Vec(a, pina));
ld h = static_cast<double>(area) / dis(a, b);
return abs(h) <= static_cast<double>(r);
};
auto invxian = [&](Point a, Point b) -> bool {
ll t = cha(Vec(a, b), Vec(a, pina));
return t < 0;
};
vector<Point> conv(n);
for (int i = 0; i < n; ++i) conv[i].read();
int p = 0, q = 0;
ll ans = 0, cur = 0;
while (true) {
while (true) {
ans = max(ans, cur);
int qq = (q + 1) % n;
if (jiao(conv[p], conv[qq]) || invxian(conv[p], conv[qq])) {
break;
} else {
ll t = cha(Vec(conv[p], conv[q]), Vec(conv[p], conv[qq]));
assert(t >= 0);
cur += t;
q = qq;
}
}
int pp = p + 1;
if (pp == n) break;
ll t = cha(Vec(conv[q], conv[p]), Vec(conv[q], conv[pp]));
assert(t >= 0);
cur -= t;
assert(cur >= 0);
p = pp;
}
printf("%lld\n", ans);
}
int main() {
int t;
scanf("%d", &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: 3804kb
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: 3804kb
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'