QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#646604 | #9434. Italian Cuisine | xiachi | WA | 0ms | 3756kb | C++20 | 1.6kb | 2024-10-17 01:50:22 | 2024-10-17 01:50:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
struct Point {
LL x, y;
Point(LL x = 0, LL y = 0) : x(x), y(y) {}
void input() {
cin >> x >> y;
}
Point operator - (const Point& b) const {
return Point(x - b.x, y - b.y);
}
LL operator ^ (const Point& b) const {
return x * b.y - y * b.x;
}
LL length2() {
return x * x + y * y;
}
long double length() {
return sqrtl(length2());
}
};
int sgn(long double x) {
if (abs(x) <= 1E-7) {
return 0;
}
return x > 0 ? 1 : -1;
}
void solve() {
int n;
cin >> n;
Point c;
c.input();
LL r;
cin >> r;
vector<Point> p(n);
for (int i = 0; i < n; i++) {
p[i].input();
}
LL sum = 0, res = 0;
for (int i = 0, j = 1; i < n; i++) {
while (true) {
int k = (j + 1) % n;
LL s = (p[k] - p[i]) ^ (c - p[k]);
// if (s > 0 && s * s >= r * r * (p[k] - p[i]).length2()) {
if (s > 0 && sgn(s - (p[k] - p[i]).length() * r) >= 0) {
sum += (p[j] - p[i]) ^ (p[k] - p[j]);
j = k;
} else {
break;
}
}
res = max(res, sum);
if (sum > 0) {
// cout << i << ' ' << j << endl;
int k = (i + 1) % n;
sum -= (p[k] - p[i]) ^ (p[j] - p[k]);
}
}
cout << res << endl;
}
int main() {
ios_base::sync_with_stdio(false);
int tt;
cin >> tt;
while (tt--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3756kb
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'