QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#929 | #606267 | #9434. Italian Cuisine | LeonaRaging | shift | Failed. | 2024-10-03 13:11:13 | 2024-10-03 13:11:14 |
Details
Extra Test:
Accepted
time: 0ms
memory: 3556kb
input:
1 7 6 4 1 2 0 10 0 10 9 8 10 4 8 1 5 0 3
output:
53
result:
ok 1 number(s): "53"
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606267 | #9434. Italian Cuisine | shift | AC ✓ | 19ms | 4832kb | C++20 | 2.8kb | 2024-10-03 00:03:08 | 2024-10-03 00:03:09 |
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using T = i64;
struct Point {
T x;
T y;
Point(T x_ = 0, T y_ = 0) : x(x_), y(y_) {}
operator Point() {
return Point(x, y);
}
Point &operator+=(Point p) & {
x += p.x;
y += p.y;
return *this;
}
Point &operator-=(Point p) & {
x -= p.x;
y -= p.y;
return *this;
}
Point &operator*=(T v) & {
x *= v;
y *= v;
return *this;
}
Point operator-() const {
return Point(-x, -y);
}
friend Point operator+(Point a, Point b) {
return a += b;
}
friend Point operator-(Point a, Point b) {
return a -= b;
}
friend Point operator*(Point a, T b) {
return a *= b;
}
friend Point operator*(T a, Point b) {
return b *= a;
}
friend bool operator==(Point a, Point b) {
return a.x == b.x && a.y == b.y;
}
friend std::istream &operator>>(std::istream &is, Point &p) {
return is >> p.x >> p.y;
}
friend std::ostream &operator<<(std::ostream &os, Point p) {
return os << "(" << p.x << ", " << p.y << ")";
}
};
using i128 = __int128;
std::ostream &operator<<(std::ostream &os, i128 n) {
std::string s;
while (n) {
s += '0' + n % 10;
n /= 10;
}
std::reverse(s.begin(), s.end());
return os << s;
}
T dot(Point a, Point b) {
return a.x * b.x + a.y * b.y;
}
T cross(Point a, Point b) {
return a.x * b.y - a.y * b.x;
}
bool Point_to_Line(Point A, Point B, Point O, i64 r) {
auto v1 = B - A, v2 = O - A;
i128 u = cross(v1, v2);
u *= u;
i128 v = r;
v *= v;
v *= dot(v1, v1);
return u >= v;
}
void solve() {
int n;
std::cin >> n;
i64 r;
Point o;
std::cin >> o >> r;
std::vector<Point> h(n);
for(int i = 0; i < n; i ++ ) {
std::cin >> h[i];
}
auto check = [&](int i, int j) -> bool {
return Point_to_Line(h[i], h[j], o, r) and cross(h[j] - h[i], o - h[i]) > 0;
};
auto S = [&](int i, int j, int k) -> i64 {
return std::abs(cross(h[i] - h[j], h[j] - h[k]));
};
i64 ans = 0, cur = 0;
int next = 1;
for(int i = 0; i < n; i ++ ) {
while(check(i, (next + 1) % n)) {
cur += S(i, next, (next + 1) % n);
next += 1;
next %= n;
}
ans = std::max(ans, cur);
cur -= S(i, (i + 1) % n, next);
}
std::cout << ans << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}