This documentation is automatically generated by online-judge-tools/verification-helper
#include "my_template.hpp"
#include "geo/base.hpp"
#include "geo/pick_formula.hpp"
// 反時計回りの単純な格子多角形だけを渡す。境界点は線分上判定、
// 内点は水平半直線との交差の偶奇で数え、Pick の公式や gcd は使わない。
// 面積は生成元の三角形・長方形・欠けた長方形の面積と変換の行列式で求める。
// 凹頂点、水平辺、同一直線上の連続辺、斜めの格子辺、巨大な平行移動も確認する。
namespace {
using P = Point<ll>;
tuple<i128, i128, i128> enumerate_points(const vc<P>& a, i128 area2) {
ll xmin = a[0].x, xmax = xmin, ymin = a[0].y, ymax = ymin;
for (P p : a) {
xmin = min(xmin, p.x), xmax = max(xmax, p.x);
ymin = min(ymin, p.y), ymax = max(ymax, p.y);
}
i128 inner = 0, boundary = 0;
for (ll x = xmin; x <= xmax; ++x) {
for (ll y = ymin; y <= ymax; ++y) {
bool inside = false, on_edge = false;
for (size_t i = 0; i < a.size(); ++i) {
P p = a[i], q = a[(i + 1) % a.size()];
if (p.y > q.y) swap(p, q);
i128 side = (i128(q.x) - p.x) * (i128(y) - p.y)
- (i128(q.y) - p.y) * (i128(x) - p.x);
if (side == 0 && min(p.x, q.x) <= x && x <= max(p.x, q.x)
&& p.y <= y && y <= q.y) {
on_edge = true;
break;
}
// 上側端点を除外し、頂点を通る半直線での二重カウントを防ぐ。
if (p.y <= y && y < q.y && side > 0) inside = !inside;
}
boundary += on_edge;
inner += !on_edge && inside;
}
}
return {area2, inner, boundary};
}
void test_polygon(vc<P> points, tuple<i128, i128, i128> want, int id) {
auto got = pick_formula(points);
if (got == want) return;
cerr << "pick_formula mismatch at case " << id << ':';
for (P p : points) cerr << " (" << p.x << ',' << p.y << ')';
cerr << "; area2/inner/boundary agreement = "
<< (get<0>(got) == get<0>(want)) << '/'
<< (get<1>(got) == get<1>(want)) << '/'
<< (get<2>(got) == get<2>(want)) << '\n';
abort();
}
} // namespace
int main() {
int id = 0;
const array<array<ll, 4>, 4> matrices{{
{1, 0, 0, 1}, {1, 2, -1, 1}, {0, -2, 1, 1}, {-2, 1, -1, -1}
}};
constexpr ll big = 4'000'000'000'000'000'000LL;
auto check = [&](const vc<P>& shape, ll base_area2) {
for (auto [a, b, c, d] : matrices) {
for (auto [sx, sy] : {pair<ll, ll>{-13, 11}, {big, -big}, {-big, big}}) {
vc<P> poly;
for (P p : shape) poly.emplace_back(a * p.x + b * p.y + sx,
c * p.x + d * p.y + sy);
rotate(poly.begin(), poly.begin() + (id % poly.size()), poly.end());
test_polygon(poly, enumerate_points(poly, base_area2 * (a*d - b*c)), id++);
}
}
};
for (ll w = 1; w <= 5; ++w) {
for (ll h = 1; h <= 5; ++h) {
check({{0, 0}, {w, 0}, {0, h}}, w*h);
for (ll cut_x = 1; cut_x < w; ++cut_x) {
check({{0, 0}, {cut_x, 0}, {w, 0}, {w, h}, {0, h}}, 2*w*h);
for (ll cut_y = 1; cut_y < h; ++cut_y) {
check({{0, 0}, {w, 0}, {w, cut_y}, {cut_x, cut_y}, {cut_x, h}, {0, h}},
2*(w*h - (w-cut_x)*(h-cut_y)));
}
}
}
}
// 内点数と面積が 64 bit に収まらないケース。長方形だけは閉形式で検査する。
constexpr ll w = 4'000'000'001LL, h = 4'000'000'003LL;
test_polygon({{-big, big}, {-big+w, big}, {-big+w, big+h}, {-big, big+h}},
{2*i128(w)*h, i128(w-1)*(h-1), 2*i128(w+h)}, id++);
cout << "pick_formula: " << id << " cases passed\n";
}#line 1 "my_template.hpp"
// Source: https://github.com/maspypy/library/blob/main/my_template.hpp
#if defined(USE_PCH)
#include <my_template_compiled.hpp>
#if defined(__GNUC__)
#pragma GCC optimize("Ofast,unroll-loops")
#if !defined(MASPY_NON_AVX2)
#pragma GCC target("avx2,popcnt")
#endif
#endif
#else // MASPY_TEMPLATE_BODY
#include <bits/stdc++.h>
#include <cassert>
#if defined(__GNUC__)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
using namespace std;
using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class>
constexpr bool dependent_false = false;
template <class T>
constexpr T infty = [] {
static_assert(dependent_false<T>, "infty<T> is not defined");
return T{};
}();
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 4'040'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 4'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<i128>;
template <>
constexpr long double infty<long double> = infty<i128>;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using pq_max = priority_queue<T>;
template <class T>
using pq_min = priority_queue<T, vector<T>, greater<T>>;
#define vv(type, name, h, ...) \
vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) \
vector<vector<vector<type>>> name( \
h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name( \
a, vector<vector<vector<type>>>( \
b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR1_R(a) for (ll i = ll(a) - 1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = ll(a) - 1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = ll(b) - 1; i >= ll(a); --i)
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload3(__VA_ARGS__, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define len(x) ll(x.size())
#define elif else if
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define stoi stoll
// require y > 0
template <typename T>
T floor(T x, T y) {
return x / y - (x % y < 0);
}
// require y > 0
template <typename T>
T ceil(T x, T y) {
return (x / y) + (x % y > 0);
}
// require y > 0
template <typename T>
T bmod(T x, T y) {
T r = x % y;
return (r < 0 ? r + y : r);
}
// require y > 0
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = x / y, r = x % y;
if (r < 0) --q, r += y;
return {q, r};
}
constexpr auto TEN = [] {
array<u64, 20> A{};
A[0] = 1;
for (int i = 1; i < 20; ++i) A[i] = 10 * A[i - 1];
return A;
}();
template <typename T, typename U>
T SUM(const U &A) {
return std::accumulate(A.begin(), A.end(), T{});
}
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
template <class C, class T>
inline long long LB(const C &c, const T &x) {
return lower_bound(c.begin(), c.end(), x) - c.begin();
}
template <class C, class T>
inline long long UB(const C &c, const T &x) {
return upper_bound(c.begin(), c.end(), x) - c.begin();
}
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
template <typename T>
T POP(deque<T> &que) {
T a = que.front();
que.pop_front();
return a;
}
template <class T, class Container, class Compare>
T POP(priority_queue<T, Container, Compare> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
T a = que.back();
que.pop_back();
return a;
}
template <typename F>
i128 binary_search(F check, i128 ok, i128 ng, bool check_ok = true) {
if (check_ok) assert(check(ok));
while (1) {
i128 x = (ok + ng) / 2;
if (x == ok || x == ng) break;
(check(x) ? ok : ng) = x;
}
return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
FOR(iter) {
double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
T c = max<T>(a, b);
bool changed = (c != a);
a = c;
return changed;
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
T c = min<T>(a, b);
bool changed = (c != a);
a = c;
return changed;
}
// bit operations
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_sgn(int x) { return (__builtin_parity(unsigned(x)) & 1 ? -1 : 1); }
int popcnt_sgn(u32 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(ll x) { return (__builtin_parityll(x) & 1 ? -1 : 1); }
int popcnt_sgn(u64 x) { return (__builtin_parityll(x) & 1 ? -1 : 1); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
template <typename T>
T kth_bit(int k) {
assert(0 <= k && k < int(8 * sizeof(T)));
return T(1) << k;
}
template <typename T>
bool has_kth_bit(T x, int k) {
assert(0 <= k && k < int(8 * sizeof(T)));
return x >> k & 1;
}
template <typename T>
struct all_bit {
static_assert(is_integral<T>::value);
T s;
all_bit(T s) : s(s) { assert(s >= 0); }
struct iter {
T s;
int operator*() const { return lowbit(s); }
void operator++() { s &= s - 1; }
bool operator!=(nullptr_t) const { return s; }
};
iter begin() const { return {s}; }
nullptr_t end() const { return nullptr; }
};
template <typename T>
struct all_subset {
static_assert(is_integral<T>::value);
T s;
all_subset(T s) : s(s) { assert(s >= 0); }
struct iter {
T s, t;
bool done = false;
T operator*() const { return t; }
void operator++() {
done = (t == 0);
t = (t - 1) & s;
}
bool operator!=(nullptr_t) const { return !done; }
};
iter begin() const { return {s, s}; }
nullptr_t end() const { return nullptr; }
};
constexpr u64 full_mask(int n) {
assert(0 <= n && n <= 64);
return n == 64 ? -1ULL : (1ULL << n) - 1;
}
u64 bit_reverse(u64 x) {
x = ((x & 0x5555555555555555ULL) << 1) | ((x >> 1) & 0x5555555555555555ULL);
x = ((x & 0x3333333333333333ULL) << 2) | ((x >> 2) & 0x3333333333333333ULL);
x = ((x & 0x0f0f0f0f0f0f0f0fULL) << 4) | ((x >> 4) & 0x0f0f0f0f0f0f0f0fULL);
x = ((x & 0x00ff00ff00ff00ffULL) << 8) | ((x >> 8) & 0x00ff00ff00ff00ffULL);
x = ((x & 0x0000ffff0000ffffULL) << 16) | ((x >> 16) & 0x0000ffff0000ffffULL);
x = (x << 32) | (x >> 32);
return x;
}
// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
vc<int> A(S.size());
FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
return A;
}
template <typename T, typename U>
vc<T> cumsum(const vc<U> &A, int off = 1) {
int N = A.size();
vc<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0) B.erase(B.begin());
return B;
}
// stable sort
template <typename T>
vc<int> argsort(const vc<T> &A) {
vc<int> ids(len(A));
iota(all(ids), 0);
sort(all(ids),
[&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
vc<T> B(len(I));
FOR(i, len(I)) B[i] = A[I[i]];
return B;
}
template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &...others) {
size_t n = first.size() + (others.size() + ... + 0);
if (n > first.capacity()) {
first.reserve(max(n, 2 * first.capacity()));
}
(first.insert(first.end(), others.begin(), others.end()), ...);
}
// i128
template <class T, enable_if_t<is_same_v<T, i128>, int> = 0>
constexpr i128 abs(T x) {
return x < 0 ? -x : x;
}
constexpr i128 gcd(i128 a, i128 b) {
while (b != 0) {
i128 c = a % b;
a = b, b = c;
}
return abs(a);
}
#endif // MASPY_TEMPLATE_BODY
#line 1 "geo/base.hpp"
// Source: https://github.com/maspypy/library/blob/main/geo/base.hpp
template <typename T>
struct Point {
T x, y;
Point() : x(0), y(0) {}
template <typename A, typename B>
Point(A x, B y) : x(x), y(y) {}
template <typename A, typename B>
Point(pair<A, B> p) : x(p.fi), y(p.se) {}
template <typename U>
Point(Point<U> p) : x(p.x), y(p.y) {
static_assert(!is_integral_v<T> || is_integral_v<U>);
}
Point operator+=(const Point p) {
x += p.x, y += p.y;
return *this;
}
Point operator-=(const Point p) {
x -= p.x, y -= p.y;
return *this;
}
Point operator+(Point p) const { return {x + p.x, y + p.y}; }
Point operator-(Point p) const { return {x - p.x, y - p.y}; }
bool operator==(Point p) const { return x == p.x && y == p.y; }
bool operator!=(Point p) const { return x != p.x || y != p.y; }
Point operator-() const { return {-x, -y}; }
Point operator*(T t) const { return {x * t, y * t}; }
Point operator/(T t) const { return {x / t, y / t}; }
bool operator<(Point p) const {
if (x != p.x) return x < p.x;
return y < p.y;
}
T dot(const Point& other) const { return x * other.x + y * other.y; }
T det(const Point& other) const { return x * other.y - y * other.x; }
double norm() { return sqrtl(x * x + y * y); }
double angle() { return atan2(y, x); }
Point rotate(double theta) {
static_assert(!is_integral<T>::value);
double c = cos(theta), s = sin(theta);
return Point{c * x - s * y, s * x + c * y};
}
Point rot90(bool ccw) { return (ccw ? Point{-y, x} : Point{y, -x}); }
};
#ifdef FASTIO
template <typename T>
void rd(Point<T>& p) {
fastio::rd(p.x), fastio::rd(p.y);
}
template <typename T>
void wt(Point<T>& p) {
fastio::wt(p.x);
fastio::wt(' ');
fastio::wt(p.y);
}
#endif
// A -> B -> C と進むときに、左に曲がるならば +1、右に曲がるならば -1
template <typename T>
int ccw(Point<T> A, Point<T> B, Point<T> C) {
T x = (B - A).det(C - A);
if (x > 0) return 1;
if (x < 0) return -1;
return 0;
}
template <typename REAL, typename T, typename U>
REAL distance(Point<T> A, Point<U> B) {
REAL dx = REAL(A.x) - REAL(B.x);
REAL dy = REAL(A.y) - REAL(B.y);
return sqrt(dx * dx + dy * dy);
}
// ax+by+c
template <typename T>
struct Line {
T a, b, c;
Line(T a, T b, T c) : a(a), b(b), c(c) { assert(a != 0 || b != 0); }
Line(Point<T> A, Point<T> B) {
a = A.y - B.y, b = B.x - A.x, c = A.x * B.y - A.y * B.x;
assert(a != 0 || b != 0);
}
Line(T x1, T y1, T x2, T y2) : Line(Point<T>(x1, y1), Point<T>(x2, y2)) {}
template <typename U>
auto eval(Point<U> P) const {
return eval(P.x, P.y);
}
template <typename U>
auto eval(U x, U y) const {
return a * x + b * y + c;
}
// 同じ直線が同じ a,b,c で表現されるようにする
void normalize() {
static_assert(is_same_v<T, int> || is_same_v<T, long long>);
T g = gcd(gcd(abs(a), abs(b)), abs(c));
a /= g, b /= g, c /= g;
if (b < 0) {
a = -a, b = -b, c = -c;
}
if (b == 0 && a < 0) {
a = -a, b = -b, c = -c;
}
}
bool is_parallel(Line other) { return a * other.b - b * other.a == 0; }
bool is_orthogonal(Line other) { return a * other.a + b * other.b == 0; }
bool is_same(Line other) {
if (a * other.b != b * other.a) return 0;
if (a * other.c != c * other.a) return 0;
if (b * other.c != c * other.b) return 0;
return 1;
}
};
template <typename T>
struct Segment {
Point<T> A, B;
Segment(Point<T> A, Point<T> B) : A(A), B(B) { assert(A != B); }
Segment(T x1, T y1, T x2, T y2)
: Segment(Point<T>(x1, y1), Point<T>(x2, y2)) {}
bool contain(Point<T> C) {
T det = (C - A).det(B - A);
if (det != 0) return 0;
return (C - A).dot(B - A) >= 0 && (C - B).dot(A - B) >= 0;
}
Line<T> to_line() { return Line(A, B); }
};
template <typename REAL>
struct Circle {
Point<REAL> O;
REAL r;
Circle() {}
Circle(Point<REAL> O, REAL r) : O(O), r(r) {}
Circle(REAL x, REAL y, REAL r) : O(x, y), r(r) {}
template <typename T>
bool contain(Point<T> p) {
REAL dx = p.x - O.x, dy = p.y - O.y;
return dx * dx + dy * dy <= r * r;
}
};
#line 1 "geo/pick_formula.hpp"
// Source: https://github.com/maspypy/library/blob/main/geo/pick_formula.hpp
// input: ccw simple polygon
// return: area2, inner, boundary
template <typename T>
tuple<i128, i128, i128> pick_formula(vc<Point<T>>& A) {
using P = Point<T>;
int N = len(A);
i128 area2 = 0;
i128 bd = 0;
FOR(i, N) {
P a = A[i], b = A[(i + 1) % N];
area2 += i128(a.x) * b.y - i128(a.y) * b.x;
P d = b - a;
bd += gcd(d.x, d.y);
}
assert(area2 >= 0);
i128 in = (area2 + 2 - bd) / 2;
return {area2, in, bd};
}
#line 4 "test/5_ai_generated_test/pick_formula_ccw_lattice_points.test.cpp"
// 反時計回りの単純な格子多角形だけを渡す。境界点は線分上判定、
// 内点は水平半直線との交差の偶奇で数え、Pick の公式や gcd は使わない。
// 面積は生成元の三角形・長方形・欠けた長方形の面積と変換の行列式で求める。
// 凹頂点、水平辺、同一直線上の連続辺、斜めの格子辺、巨大な平行移動も確認する。
namespace {
using P = Point<ll>;
tuple<i128, i128, i128> enumerate_points(const vc<P>& a, i128 area2) {
ll xmin = a[0].x, xmax = xmin, ymin = a[0].y, ymax = ymin;
for (P p : a) {
xmin = min(xmin, p.x), xmax = max(xmax, p.x);
ymin = min(ymin, p.y), ymax = max(ymax, p.y);
}
i128 inner = 0, boundary = 0;
for (ll x = xmin; x <= xmax; ++x) {
for (ll y = ymin; y <= ymax; ++y) {
bool inside = false, on_edge = false;
for (size_t i = 0; i < a.size(); ++i) {
P p = a[i], q = a[(i + 1) % a.size()];
if (p.y > q.y) swap(p, q);
i128 side = (i128(q.x) - p.x) * (i128(y) - p.y)
- (i128(q.y) - p.y) * (i128(x) - p.x);
if (side == 0 && min(p.x, q.x) <= x && x <= max(p.x, q.x)
&& p.y <= y && y <= q.y) {
on_edge = true;
break;
}
// 上側端点を除外し、頂点を通る半直線での二重カウントを防ぐ。
if (p.y <= y && y < q.y && side > 0) inside = !inside;
}
boundary += on_edge;
inner += !on_edge && inside;
}
}
return {area2, inner, boundary};
}
void test_polygon(vc<P> points, tuple<i128, i128, i128> want, int id) {
auto got = pick_formula(points);
if (got == want) return;
cerr << "pick_formula mismatch at case " << id << ':';
for (P p : points) cerr << " (" << p.x << ',' << p.y << ')';
cerr << "; area2/inner/boundary agreement = "
<< (get<0>(got) == get<0>(want)) << '/'
<< (get<1>(got) == get<1>(want)) << '/'
<< (get<2>(got) == get<2>(want)) << '\n';
abort();
}
} // namespace
int main() {
int id = 0;
const array<array<ll, 4>, 4> matrices{{
{1, 0, 0, 1}, {1, 2, -1, 1}, {0, -2, 1, 1}, {-2, 1, -1, -1}
}};
constexpr ll big = 4'000'000'000'000'000'000LL;
auto check = [&](const vc<P>& shape, ll base_area2) {
for (auto [a, b, c, d] : matrices) {
for (auto [sx, sy] : {pair<ll, ll>{-13, 11}, {big, -big}, {-big, big}}) {
vc<P> poly;
for (P p : shape) poly.emplace_back(a * p.x + b * p.y + sx,
c * p.x + d * p.y + sy);
rotate(poly.begin(), poly.begin() + (id % poly.size()), poly.end());
test_polygon(poly, enumerate_points(poly, base_area2 * (a*d - b*c)), id++);
}
}
};
for (ll w = 1; w <= 5; ++w) {
for (ll h = 1; h <= 5; ++h) {
check({{0, 0}, {w, 0}, {0, h}}, w*h);
for (ll cut_x = 1; cut_x < w; ++cut_x) {
check({{0, 0}, {cut_x, 0}, {w, 0}, {w, h}, {0, h}}, 2*w*h);
for (ll cut_y = 1; cut_y < h; ++cut_y) {
check({{0, 0}, {w, 0}, {w, cut_y}, {cut_x, cut_y}, {cut_x, h}, {0, h}},
2*(w*h - (w-cut_x)*(h-cut_y)));
}
}
}
}
// 内点数と面積が 64 bit に収まらないケース。長方形だけは閉形式で検査する。
constexpr ll w = 4'000'000'001LL, h = 4'000'000'003LL;
test_polygon({{-big, big}, {-big+w, big}, {-big+w, big+h}, {-big, big+h}},
{2*i128(w)*h, i128(w-1)*(h-1), 2*i128(w+h)}, id++);
cout << "pick_formula: " << id << " cases passed\n";
}