QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#598697 | #9434. Italian Cuisine | ucup-team3584# | Compile Error | / | / | C++23 | 4.0kb | 2024-09-28 23:02:35 | 2024-09-28 23:02:36 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
// 整数幾何
using int128_t = __int128_t;
typedef int128_t Integer;
const Integer eps = 0;
inline constexpr int arg_type(Integer x, Integer y) { return y < 0 ? 2 : x < 0 ? 1 : 0; }
struct Point {
Integer x, y;
constexpr explicit Point(Integer x = 0, Integer y = 0) : x(x), y(y) {}
constexpr Point operator+() const noexcept { return *this; }
constexpr Point operator-() const noexcept { return Point(-x, -y); }
constexpr Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
constexpr Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
constexpr Point &operator+=(const Point &p) { return x += p.x, y += p.y, *this; }
constexpr Point &operator-=(const Point &p) { return x -= p.x, y -= p.y, *this; }
constexpr Point &operator*=(const Integer &k) { return x *= k, y *= k, *this; }
constexpr Point operator*(const Integer &k) const { return Point(x * k, y * k); }
constexpr bool operator==(const Point &r) const noexcept { return r.x == x and r.y == y; }
constexpr Integer dot(const Point &r) const { return x * r.x + y * r.y; }
constexpr Integer cross(const Point &r) const { return x * r.y - y * r.x; }
constexpr Integer norm2() const { return x * x + y * y; }
};
Integer dot(Point a, Point b) { return a.dot(b); }
Integer cross(Point a, Point b) { return a.cross(b); }
bool is_in_triangle(vector<Point> v, Point p) {
bool in = false;
for (int i = 0; i < v.size(); ++i) {
Point a = v[i], b = v[(i + 1) % v.size()];
a -= p, b -= p;
if (a.y > b.y) std::swap(a, b);
if (a.y <= 0 and 0 < b.y and cross(a, b) < 0) in ^= 1;
}
return in;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int q;
cin >> q;
while (q--) {
int n;
cin >> n;
Point r;
ll rr;
ll res = 0, sum = 0;
auto area = [&](Point a, Point b, Point c) -> ll {
b -= a, c -= a;
ll bx = b.x, by = b.y, cx = c.x, cy = c.y;
return abs(bx * cy - cx * by);
};
vector<Point> p(n);
{
ll x, y;
cin >> x >> y >> rr;
r.x = x, r.y = y;
for (int i = 0; i < n; ++i) {
cin >> x >> y;
p[i].x = x, p[i].y = y;
}
for (int i = 0; i < n; ++i) {
p.push_back(p[i]);
}
for (int i = 0; i < n; ++i) {
p.push_back(p[i]);
}
}
Integer R = (Integer)rr * rr;
for (int i = 0, j = 0; i < n; ++i) {
j = max(j, i + 2);
while (j < p.size()) {
vector<Point> vs = {p[i], p[j - 1], p[j]};
if (is_in_triangle(vs, r)) break;
auto check1 = [&](Point a, Point b) -> bool {
b -= a;
// sqrt(b.x * b.x + b.y * b.y) <= rr
return b.norm2() <= R;
};
auto check2 = [&]() -> bool {
Integer uo = abs(cross(r - vs[0], vs[2] - vs[0]));
Point b = vs[2] - vs[0];
// uo / dist(vs[2], vs[0]) <= rr
// uo <= rr * sqrt(b.x * b.x + b.y * b.y)
return uo * uo <= R * b.norm2();
};
if (check1(r, vs[0])) break;
if (check1(r, vs[2])) break;
if (check2()) break;
sum += area(p[i], p[j - 1], p[j]);
j += 1;
}
res = max(res, sum);
if (j > i + 2) {
sum -= area(p[i], p[i + 1], p[j - 1]);
}
}
cout << res << "\n";
}
}
Details
answer.code: In lambda function: answer.code:92:37: error: call of overloaded ‘abs(Integer)’ is ambiguous 92 | Integer uo = abs(cross(r - vs[0], vs[2] - vs[0])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/cstdlib:79, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42, from answer.code:2: /usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’ 840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ In file included from /usr/include/c++/13/cstdlib:81: /usr/include/c++/13/bits/std_abs.h:130:3: note: candidate: ‘constexpr __gnu_cxx::__bfloat16_t std::abs(__gnu_cxx::__bfloat16_t)’ 130 | abs(__gnu_cxx::__bfloat16_t __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:124:3: note: candidate: ‘constexpr _Float128 std::abs(_Float128)’ 124 | abs(_Float128 __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:114:3: note: candidate: ‘constexpr _Float64 std::abs(_Float64)’ 114 | abs(_Float64 __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:108:3: note: candidate: ‘constexpr _Float32 std::abs(_Float32)’ 108 | abs(_Float32 __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:102:3: note: candidate: ‘constexpr _Float16 std::abs(_Float16)’ 102 | abs(_Float16 __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’ 79 | abs(long double __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’ 75 | abs(float __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’ 71 | abs(double __x) | ^~~ /usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’ 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’ 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~