QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635042 | #9434. Italian Cuisine | woodie_0064# | WA | 0ms | 6848kb | C++17 | 2.3kb | 2024-10-12 18:49:51 | 2024-10-12 18:49:51 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1e5 + 5;
int n;
ll R;
struct vec {
ll x, y;
vec(int x = 0, int y = 0) : x(x), y(y) {}
friend vec operator - (const vec &p, const vec &q) {
return vec(p.x - q.x, p.y - q.y);
}
} a[maxn * 2], c;
ll cross(vec p, vec q) {
return p.x * q.y - p.y * q.x;
}
bool check(vec p, vec q) {
// cout <<sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)) << '\n';
// cout << (p.y - q.y) * c.x << ' ' << (q.x - p.x) * c.y << ' ';
// cout << abs((p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x) << ' ';
// cout << abs((p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x)
// / sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)) << '\n';
return 1.0 * abs((p.y - q.y) * c.x + (q.x - p.x) * c.y + p.x * q.y - p.y * q.x)
/ sqrt((p.x - q.x) * (p.x - q.x) + (p.y - q.y) * (p.y - q.y)) >= R;
}
void solve() {
cin >> n >> c.x >> c.y >> R;
for(int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
a[i + n] = a[i];
}
ll ans = 0, sum1 = 0, sum2 = 0;
sum1 += cross(a[1], a[1]);
for(int i = 1; i <= n; i++) {
sum2 += cross(a[i], a[i + 1]);
}
for(int i = 1, j = 1; i <= n; i++) {
while(j + 1 - i <= n - 2 && check(a[i], a[j + 1]) && cross(a[j + 1] - a[i], c - a[i]) > 0) {
sum1 += cross(a[j], a[j + 1]);
sum1 -= cross(a[j], a[i]);
sum1 += cross(a[j + 1], a[i]);
// sum2 -= cross(a[j], a[j + 1]);
// sum2 -= cross(a[j], a[i + n]);
// sum2 += cross(a[j + 1], a[i + n]);
j++;
}
if(i < j) {
ans = max(ans, abs(sum1));
// cout << i << ' ' << j << ' ' << sum1 << '\n';
// if(cross((a[j] - a[i]), (c - a[i])) < 0) {
// ans = max(ans, sum1 / 2);
// }
// else {
// ans = max(ans, sum2 / 2);
// }
sum1 -= cross(a[i], a[i + 1]);
sum1 -= cross(a[j], a[i]);
sum1 += cross(a[j], a[i + 1]);
// sum2 += cross(a[i + n], a[i + n + 1]);
// sum2 -= cross(a[j], a[i + n]);
// sum2 += cross(a[i + n + 1], a[j]);
}
else {
j++;
}
}
cout << ans << '\n';
}
int main() {
#ifdef yczDEBUG
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
while(T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 6848kb
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: 6776kb
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'