QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649586 | #9434. Italian Cuisine | Longvu | WA | 14ms | 5704kb | C++23 | 3.8kb | 2024-10-18 02:48:32 | 2024-10-18 02:48:33 |
Judging History
answer
/**
* author: longvu
* created: 10/17/24 21:39:48
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
using i128 = __int128_t;
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(2010001);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
if (y > x) {x = y; return true;}
return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
if (y < x) {x = y; return true;}
return false;
}
template <typename T>
inline void read(T &x)
{
T f = 1;
x = 0;
char ch = getchar();
while (0 == isdigit(ch))
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (0 != isdigit(ch))
x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
x *= f;
}
template <typename T>
inline void write(T x)
{
if (x < 0)
{
x = ~(x - 1);
putchar('-');
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
struct Point {
i128 x, y;
};
using Vtor = Point;
Vtor make_vtor(Point a, Point b) {
return {b.x - a.x, b.y - a.y};
}
i128 cross(Vtor a, Vtor b) {
return a.x * b.y - a.y * b.x;
}
Point a[nax];
i128 pre[nax];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tt;
read(tt);
while (tt--) {
int n;
read(n);
Point b;
int d;
read(b.x);
read(b.y);
read(d);
vector<Point> memo;
for (int i = 0; i < n; ++i) {
read(a[i].x); read(a[i].y);
while (sz(memo) >= 2 && !cross(make_vtor(memo[sz(memo) - 2], memo.back()), make_vtor(memo.back(), a[i]))) {
memo.pop_back();
}
memo.push_back(a[i]);
}
reverse(all(memo));
while (sz(memo) >= 2 && !cross(make_vtor(memo[sz(memo) - 2], memo.back()), make_vtor(memo.back(), a[n - 1]))) {
memo.pop_back();
}
reverse(all(memo));
n = sz(memo);
for (int i = 0; i < n; ++i) {
a[i] = a[n + i] = memo[i];
}
if (n <= 2) {
cout << 0 << '\n';
continue;
}
for (int i = 0; i < 2 * n - 1; ++i) {
pre[i] = cross(a[i], a[i + 1]);
if (i) {
pre[i] += pre[i - 1];
}
}
int j = 0;
i128 ans = 0;
for (int i = 0; i < n; ++i) {
j = i + 1;
Vtor z = make_vtor(a[i], a[j + 1]);
z.x *= -1;
swap(z.x, z.y);
i128 A = z.x, B = z.y, C = - z.x * a[i].x - z.y * a[i].y
, dist = A * b.x + B * b.y + C;
if (dist < 0) {
dist *= -1;
}
while (cross(make_vtor(a[i], b), make_vtor(a[i], a[j + 1])) < 0
&& dist * dist >= (A * A + B * B) * d * d) {
j++;
Vtor z = make_vtor(a[i], a[j + 1]);
z.x *= -1;
swap(z.x, z.y);
A = z.x, B = z.y, C = - z.x * a[i].x - z.y * a[i].y
, dist = A * b.x + B * b.y + C;
if (dist < 0) {
dist *= -1;
}
}
assert(j < 2 * n);
i128 sum = pre[j - 1] - (!i ? 0 : pre[i - 1])
+ cross(a[j], a[i]);
if (sum < 0) {
sum *= -1;
}
// cout << i << " " << j << " " << sum << '\n';
maximize(ans, sum);
}
write(ans);
putchar('\n');
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5684kb
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: 0
Accepted
time: 1ms
memory: 5624kb
input:
1 6 0 0 499999993 197878055 -535013568 696616963 -535013568 696616963 40162440 696616963 499999993 -499999993 499999993 -499999993 -535013568
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 14ms
memory: 5704kb
input:
6666 19 -142 -128 26 -172 -74 -188 -86 -199 -157 -200 -172 -199 -186 -195 -200 -175 -197 -161 -188 -144 -177 -127 -162 -107 -144 -90 -126 -87 -116 -86 -104 -89 -97 -108 -86 -125 -80 -142 -74 -162 -72 16 -161 -161 17 -165 -190 -157 -196 -154 -197 -144 -200 -132 -200 -128 -191 -120 -172 -123 -163 -138...
output:
5093 3086 2539 668 3535 7421 4883 5711 5624 1034 2479 3920 4372 2044 4996 4569 2251 4382 4175 1489 1154 3231 4038 1631 5086 14444 1692 6066 687 1512 4849 5456 2675 8341 8557 8235 1013 5203 10853 6042 6300 4480 2303 2728 1739 2187 3385 4266 6322 909 4334 1518 948 5036 1449 2376 3180 4810 1443 1786 46...
result:
wrong answer 16th numbers differ - expected: '5070', found: '4569'