QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606196 | #9434. Italian Cuisine | shift | WA | 13ms | 3856kb | C++20 | 2.7kb | 2024-10-02 23:05:44 | 2024-10-02 23:05:45 |
Judging History
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 << ")";
}
};
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;
}
long double Point_to_Line(Point A, Point B, Point O) {
auto v1 = B - A, v2 = O - A;
return (long double)(cross(v1, v2) * cross(v1, v2)) / dot(v1, v1);
}
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 * 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(next != i and check(i, (next + 1) % n)) {
cur += S(i, next, next + 1);
next += 1;
next %= n;
}
ans = std::max(ans, cur);
if(next == (i + 1) % n) {
next = (next + 1) % n;
} else {
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
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: 0ms
memory: 3540kb
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: 13ms
memory: 3856kb
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:
7312110 610181 4948067 2923622 4219042 2394222 712594 5579837 33631 592704 3775 25493 22757 10974 8797 20518 7064 782295 5245754 3416 3267 26193 4921 11234 9938 69692 8564 11077 3674 20732 7429879 26991 2863295 64043 21757 41709 21064 22424 16848 25257 8312220 27772 8775 26084 11585 28355 6283 24183...
result:
wrong answer 1st numbers differ - expected: '5093', found: '7312110'