QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#647199 | #7693. Convex Hull Extension | crimson231 | AC ✓ | 1ms | 3912kb | C++17 | 9.8kb | 2024-10-17 12:37:59 | 2024-10-17 12:38:00 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <vector>
#include <random>
#include <array>
#include <tuple>
typedef long long ll;
//typedef long double ld;
typedef double ld;
typedef std::vector<int> Vint;
typedef std::vector<ll> Vll;
typedef std::vector<ld> Vld;
const ll INF = 1e17;
const int LEN = 1e5 + 1;
const ld TOL = 1e-10;
inline int sign(const ld& x) { return x < -TOL ? -1 : x > TOL; }
inline bool zero(const ld& x) { return !sign(x); }
inline ll sq(int x) { return (ll)x * x; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
//ll gcd(ll a, ll b) { while (b) { ll tmp = a % b; a = b; b = tmp; } return a; }
inline ld tol(const ld& x) { return x + TOL * (x / std::abs(x)); }
//#define DEBUG
#define WHAT_THE_FUCK
//Pick`s Theorem : A = i + b/2 - 1
int N, M, T, Q;
struct Pos {
ll x, y;
ll den;
Pos(ll X = 0, ll Y = 0, ll d = 0) : x(X), y(Y), den(d) {}
bool operator == (const Pos& p) const { return x == p.x && y == p.y; }
bool operator != (const Pos& p) const { return x != p.x || y != p.y; }
bool operator < (const Pos& p) const { return x == p.x ? y < p.y : x < p.x; }
bool operator <= (const Pos& p) const { return x == p.x ? y <= p.y : x <= p.x; }
Pos operator + (const Pos& p) const { return { x + p.x, y + p.y }; }
Pos operator - (const Pos& p) const { return { x - p.x, y - p.y }; }
Pos operator * (const ll& n) const { return { x * n, y * n }; }
Pos operator / (const ll& n) const { return { x / n, y / n }; }
ll operator * (const Pos& p) const { return (ll)x * p.x + (ll)y * p.y; }
ll operator / (const Pos& p) const { return (ll)x * p.y - (ll)y * p.x; }
Pos& operator += (const Pos& p) { x += p.x; y += p.y; return *this; }
Pos& operator -= (const Pos& p) { x -= p.x; y -= p.y; return *this; }
Pos& operator *= (const ll& scale) { x *= scale; y *= scale; return *this; }
Pos& operator /= (const ll& scale) { x /= scale; y /= scale; return *this; }
Pos operator - () const { return { -x, -y }; }
Pos operator ~ () const { return { -y, x }; }
Pos operator ! () const { return { y, x }; }
ll Euc() const { return (ll)x * x + (ll)y * y; }
ll Man() const { return std::abs(x) + std::abs(y); }
ld mag() const { return hypot(x, y); }
ld rad() const { return atan2(y, x); }
friend ld rad(const Pos& p1, const Pos& p2) { return atan2l(p1 / p2, p1 * p2); }
friend std::istream& operator >> (std::istream& is, Pos& p) { is >> p.x >> p.y; return is; }
friend std::ostream& operator << (std::ostream& os, const Pos& p) { os << p.x << " " << p.y; return os; }
ll modx() const { return std::abs(x) % std::abs(den); }
ll mody() const { return std::abs(y) % std::abs(den); }
bool x_int() const { return !modx(); }
bool y_int() const { return !mody(); }
bool is_int() const { return !modx() && !mody(); }
ld x_() const { return x * 1. / den; }
ld y_() const { return y * 1. / den; }
Pos p() const { return Pos(x / den, y / den); }
}; const Pos O = Pos(0, 0);
typedef std::vector<Pos> Polygon;
ll cross(const Pos& d1, const Pos& d2, const Pos& d3) { return (d2 - d1) / (d3 - d2); }
ll cross(const Pos& d1, const Pos& d2, const Pos& d3, const Pos& d4) { return (d2 - d1) / (d4 - d3); }
ll dot(const Pos& d1, const Pos& d2, const Pos& d3) { return (d2 - d1) * (d3 - d2); }
ll dot(const Pos& d1, const Pos& d2, const Pos& d3, const Pos& d4) { return (d2 - d1) * (d4 - d3); }
int ccw(const Pos& d1, const Pos& d2, const Pos& d3) { ll ret = cross(d1, d2, d3); return !ret ? 0 : ret > 0 ? 1 : -1; }
int ccw(const Pos& d1, const Pos& d2, const Pos& d3, const Pos& d4) { ll ret = cross(d1, d2, d3, d4); return !ret ? 0 : ret > 0 ? 1 : -1; }
ll area(const Polygon& H) {
ll ret = 0;
int sz = H.size();
for (int i = 0; i < sz; i++) ret += H[i] / H[(i + 1) % sz];
return ret;
}
void norm(Polygon& H) { ll A = area(H); if (A < 0) std::reverse(H.begin(), H.end()); return; }
Pos intersection(const Pos& p1, const Pos& p2, const Pos& q1, const Pos& q2) {
ll a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
ll x = (p1.x * a2 + p2.x * a1);
ll y = (p1.y * a2 + p2.y * a1);
Pos ret = Pos(x, y);
ret.den = a1 + a2;
return ret;
}
ld get_y(Pos p0, Pos p1, ld x) {
if (p1.x < p0.x) std::swap(p1, p0);
Pos vec = p1 - p0;
ld d = (ld)vec.y / vec.x;
return p0.y + (x - p0.x) * d;
}
ll gcd(const Pos& p) { return gcd(std::abs(p.x), std::abs(p.y)); }
ll pick(const Pos& p0, const Pos& p1, const ll& y) {
if (std::abs(p0.x - p1.x) <= 1) return 0;
ll cnt = 0;
ll dx = (ll)p0.x - p1.x;
ll dy = (ll)p0.y - p1.y;
ll _gcd = gcd(std::abs(dx), std::abs(dy));
ll A2 = std::abs(dx * ((ll)p0.y + p1.y - y - y));
ll b = _gcd + std::abs(p0.y - y) + std::abs(p1.y - y) + std::abs(dx);
//Pick`s Theorem : A = i + b / 2 - 1
ll i = (A2 - b + 2);
assert(!(i & 1ll));
return i >> 1;
}
ll remain_count(const Pos& p0, const Pos& p1, Pos s, const ll& x, const ll& y) {
Pos v = p1 - p0;
assert(v.x);
ll dx = v.x / std::abs(v.x);
int sz = (x - s.x) * dx;
#ifdef DEBUG
std::cout << "REMAIN:: s:: " << s << "\n";
std::cout << "REMAIN:: x:: " << x << "\n";
std::cout << "REMAIN:: sz:: " << sz << "\n";
#endif
if (!v.y) {
if (sz < 0) return 0;
return (std::abs(x - s.x) + 1) * (s.y - y - 1);
}
ll dy = v.y / std::abs(v.y);
assert(sz <= 2005);
ll cnt = 0;
while (sz-- >= 0) {
while (dx * dy * ccw(p0, p1, s) < 0) s.y += dy;
if (dx * ccw(p0, p1, s) >= 0) s.y--;
cnt += s.y - y;
s.x += dx;
}
#ifdef DEBUG
std::cout << "REMAIN:: cnt:: " << cnt << "\n";
#endif
return cnt;
}
ll count(const Pos& p0, const Pos& p1, const Pos& p, const ll& miny, const ll& minx, const ll& dx) {
if (!dx) {
if (p0.x != minx) return 0;
if (!p.den) return -std::abs(p0.y - p1.y);
ll ty = p1.y;
ll by = (p.y_int()) ? p.y / p.den : floor(p.y_());
return -std::abs(ty - by);
}
ll cnt = 0;
Pos v = p1 - p0;
if (!p.den) {//p1 - p2
cnt = pick(p0, p1, miny);
if (dx < 0) return -(cnt + (p1.y - miny) + (gcd(v) - 1));
return cnt + (p0.y - miny) - (p0.x != minx);
}
v /= gcd(v);
ll vx = ll(p.x_() - p1.x);
if (p.x_int()) vx = (p.x / p.den - p1.x) - (v.x / std::abs(v.x));
ll n = std::abs(vx) / std::abs(v.x);
ll X = p1.x + vx;
Pos q0;
if (p.is_int()) q0 = p.p();
else q0 = p1 + v * n;
ll tmp = pick(p1, q0, miny);
cnt += tmp;
#ifdef DEBUG
std::cout << "CNT before remain:: " << cnt << "\n";
#endif
if (q0.x == p1.x) q0.x += v.x / std::abs(v.x);
cnt += remain_count(p0, p1, q0, X, miny);
//if ((!cnt && std::abs(p1.x - p.x_()) > 1.) || cnt)
// cnt += remain_count(p0, p1, q0, X, miny);
#ifdef DEBUG
std::cout << "CNT after remain:: " << cnt << "\n";
std::cout << " n:: " << n << "\n";
#endif
Pos w0 = p1, w1 = p1;
if (w1.x < w0.x) std::swap(w0, w1);
if (p.x_int() && p.x_() < w0.x) {
ll y = p.y_int() ? p.y / p.den : floor(p.y_());
cnt += y - miny;
if (dx > 0 && p.p().x != minx && p.y_int()) cnt--;
#ifdef DEBUG
std::cout << "CNT left++ :: " << cnt << "\n";
#endif
}
else if (p.x_() > w0.x) {
cnt += w0.y - miny;
if (dx > 0 && w0.x != minx) cnt--;
#ifdef DEBUG
std::cout << "CNT left++ :: " << cnt << "\n";
#endif
}
if (dx < 0) { cnt += n; cnt *= -1ll; }
#ifdef DEBUG
std::cout << "CNT total:: " << cnt << "\n";
#endif
return cnt;
}
ll count(Pos p0, Pos p1, Pos p2, Pos p3) {
ll cnt = 0;
Pos p = intersection(p0, p1, p2, p3);
assert(p.den);
ll minx = floor(p.x_());
if (p.x_int()) minx = p.p().x;
minx = std::min({ minx, p1.x, p2.x });
ll miny = floor(p.y_());
miny = std::min({ miny, p0.y, p1.y, p2.y, p3.y }) - 1;
Pos z = Pos(0, 0, 0);
#ifndef DEBUG
cnt += count(p0, p1, p, miny, minx, p0.x - p1.x);
cnt += count(p1, p2, z, miny, minx, p2.x - p1.x);
cnt += count(p3, p2, p, miny, minx, p2.x - p3.x);
#else
ll tmp;
std::cout << "\nCOUNT::\nDEBUG:: Y:: " << miny << " X:: " << minx << "\n\n";
std::cout << "DEBUG:: p0:: " << p0 << " p1:: " << p1 << " p2:: " << p2 << " p3:: " << p3 << "\n\n";
std::cout << "DEBUG:: intersection:: " << p.x_() << " " << p.y_() << "\n\n";
std::cout << "DEBUG:: p0:: " << p0 << " p1:: " << p1 << "\n";
tmp = count(p0, p1, p, miny, minx, p0.x - p1.x);
cnt += tmp;
std::cout << "DEBUG:: p0, p1:: tmp:: " << tmp << "\n\n";
std::cout << "DEBUG:: p1:: " << p1 << " p2: " << p2 << "\n";
tmp = count(p1, p2, z, miny, minx, p2.x - p1.x);
cnt += tmp;
std::cout << "DEBUG:: p1, p2:: tmp:: " << tmp << "\n\n";
std::cout << "DEBUG:: p2:: " << p2 << " p3:: " << p3 << "\n";
tmp = count(p3, p2, p, miny, minx, p2.x - p3.x);
cnt += tmp;
std::cout << "DEBUG:: p2, p3:: tmp:: " << tmp << "\n\n";
std::cout << "DEBUG:: CNT:: " << cnt << "\n";
#endif
return cnt;
}
void solve() {
std::cin.tie(0)->sync_with_stdio(0);
std::cout.tie(0);
std::cout << std::fixed;
std::cout.precision(9);
std::cin >> N;
Polygon H(N);
for (Pos& p : H) std::cin >> p;
norm(H);
if (N == 3) { std::cout << "infinitely many\n"; return; }
if (N == 4) {
const Pos& p0 = H[0], p1 = H[1], p2 = H[2], p3 = H[3];
if (!cross(p0, p1, p2, p3) && !cross(p1, p2, p3, p0) && area(H) == 2) { std::cout << "0\n"; return; }
}
ll ret = 0;
for (int i = 0; i < N; i++) {
const Pos& p0 = H[(i - 1 + N) % N], p1 = H[i], p2 = H[(i + 1) % N], p3 = H[(i + 2) % N];
if (ccw(p0, p1, p2, p3) <= 0) {
std::cout << "infinitely many\n";
return;
}
ll cnt = count(p0, p1, p2, p3);
#ifdef DEBUG
std::cout << "\n";
std::cout << "CNT:: " << cnt << "\n";
std::cout << "\n";
#endif
ret += cnt;
}
std::cout << ret << "\n";
return;
}
int main() { solve(); return 0; }//boj30526
/*
5
0 2
-2 0
-1 -3
1 -3
2 1
23
8
0 2
0 1
1 0
2 0
3 1
3 2
2 3
1 3
0
6
0 0
400 1
400 2
0 3
-400 2
-400 1
1596
6
999 0
499 865
-499 865
-999 0
-499 -865
499 -865
2588522
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3660kb
input:
5 0 2 -2 0 -1 -3 1 -3 2 1
output:
23
result:
ok single line: '23'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 -7 -7 7 -7 7 7 -7 7
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
4 -1000 1000 -1000 999 -999 999 -999 1000
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
6 0 -901 900 -900 900 900 0 901 -900 900 -900 -900
output:
1457999998
result:
ok single line: '1457999998'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
6 900 -900 901 0 900 900 -900 900 -901 0 -900 -900
output:
1457999998
result:
ok single line: '1457999998'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
6 0 0 400 1 400 2 0 3 -400 2 -400 1
output:
1596
result:
ok single line: '1596'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
6 0 -901 900 -899 900 900 0 901 -900 900 -900 -899
output:
970921796
result:
ok single line: '970921796'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
6 2 -2 401 399 399 401 -2 2 -401 -399 -399 -401
output:
4794
result:
ok single line: '4794'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
6 399 -401 401 -399 2 2 -399 401 -401 399 -2 -2
output:
4794
result:
ok single line: '4794'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
4 -1 -1 -2 -2 -2 -3 -1 -2
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
4 0 0 0 1 -1 2 -1 1
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
48 5 -70 14 -68 22 -66 31 -63 39 -58 46 -52 52 -46 58 -39 63 -31 66 -22 68 -14 70 -5 70 5 68 14 66 22 63 31 58 39 52 46 46 52 39 58 31 63 22 66 14 68 5 70 -5 70 -14 68 -22 66 -31 63 -39 58 -46 52 -52 46 -58 39 -63 31 -66 22 -68 14 -70 5 -70 -5 -68 -14 -66 -22 -63 -31 -58 -39 -52 -46 -46 -52 -39 -58 ...
output:
36
result:
ok single line: '36'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4 -10 -10 -11 11 -11 10 -10 -11
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
4 10 -10 10 -11 11 10 11 11
output:
0
result:
ok single line: '0'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4 5 5 6 5 -5 6 -6 6
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
4 100 -99 -99 -98 -100 -98 99 -99
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
4 0 1 -1 0 0 -1 1 0
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4 -1000 0 0 -1000 1000 0 0 1000
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
4 -1000 1000 -1000 -1000 1000 -1000 1000 1000
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 0 0 0 2 -1 2 -1 1
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
4 -3 -2 -4 -2 -4 -3 -3 -4
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
4 6 -2 5 -2 4 -3 6 -3
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
48 4 -60 12 -59 19 -57 26 -54 33 -50 39 -45 45 -39 50 -33 54 -26 57 -19 59 -12 60 -4 60 4 59 12 57 19 54 26 50 33 45 39 39 45 33 50 26 54 19 57 12 59 4 60 -4 60 -12 59 -19 57 -26 54 -33 50 -39 45 -45 39 -50 33 -54 26 -57 19 -59 12 -60 4 -60 -4 -59 -12 -57 -19 -54 -26 -50 -33 -45 -39 -39 -45 -33 -50 ...
output:
40
result:
ok single line: '40'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
4 7 3 7 4 5 4 6 3
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
4 -1000 0 -999 -1000 -998 0 -999 1000
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
4 0 -1000 1000 -999 0 -998 -1000 -999
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
3 999 -1000 1000 -1000 1000 -999
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3 -2 -1 -2 -2 -1 -2
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 -1 0 0 1 -1 1
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
3 5 0 5 1 4 1
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 -777 -777 777 776 0 0
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
3 42 -13 42 -14 44 -13
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
3 -123 55 -122 57 -123 57
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
48 7 -99 19 -98 32 -94 44 -89 55 -83 66 -75 75 -66 83 -55 89 -44 94 -32 98 -19 99 -7 99 7 98 19 94 32 89 44 83 55 75 66 66 75 55 83 44 89 32 94 19 98 7 99 -7 99 -19 98 -32 94 -44 89 -55 83 -66 75 -75 66 -83 55 -89 44 -94 32 -98 19 -99 7 -99 -7 -98 -19 -94 -32 -89 -44 -83 -55 -75 -66 -66 -75 -55 -83 ...
output:
156
result:
ok single line: '156'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 0 -1000 1000 -999 999 1000 -1000 1000 -1000 -999
output:
7986005002
result:
ok single line: '7986005002'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
6 -999 1000 -1000 0 -999 -1000 999 -1000 999 -1 998 999
output:
2992004004
result:
ok single line: '2992004004'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
12 -923 -771 -612 -869 778 -976 933 -289 930 553 907 731 845 822 324 920 -913 699 -957 596 -967 269 -946 -455
output:
609372
result:
ok single line: '609372'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
9 -497 -908 741 -696 978 -393 892 690 863 986 -510 934 -672 659 -972 60 -963 -762
output:
1867855
result:
ok single line: '1867855'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
21 -804 -988 -393 -993 806 -997 893 -982 986 -870 996 -744 1000 -268 1000 194 999 638 997 666 971 928 957 943 828 989 778 992 501 997 -692 1000 -964 991 -990 936 -993 521 -995 -929 -965 -956
output:
34183
result:
ok single line: '34183'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
15 -947 -801 -516 -997 427 -998 541 -998 566 -997 927 -966 990 -932 998 471 991 896 817 964 536 997 -715 998 -868 922 -993 664 -958 -492
output:
170756
result:
ok single line: '170756'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 1000 998 -999 1000 -1000 999 -998 -999 999 -1000
output:
5326010345
result:
ok single line: '5326010345'
Test #42:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
8 0 2 0 1 1 0 2 0 3 1 3 2 2 3 1 3
output:
0
result:
ok single line: '0'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 1000 0 999 1000 -1000 999 -1000 -1000 999 -1000
output:
7986005002
result:
ok single line: '7986005002'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
5 0 1000 -1000 999 -999 -1000 1000 -1000 1000 999
output:
7986005002
result:
ok single line: '7986005002'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 1000 1000 999 1000 999 999 1000 999
output:
0
result:
ok single line: '0'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
5 -1000 0 -999 -1000 1000 -999 1000 1000 -999 1000
output:
7986005002
result:
ok single line: '7986005002'
Test #47:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
50 883 0 876 110 855 219 820 325 773 425 714 519 643 604 562 680 473 745 375 798 272 839 165 867 55 881 -55 881 -165 867 -272 839 -375 798 -473 745 -562 680 -643 604 -714 519 -773 425 -820 325 -855 219 -876 110 -883 0 -876 -110 -855 -219 -820 -325 -773 -425 -714 -519 -643 -604 -562 -680 -473 -745 -3...
output:
19136
result:
ok single line: '19136'
Test #48:
score: 0
Accepted
time: 1ms
memory: 3856kb
input:
49 750 0 743 95 725 190 695 281 653 368 601 448 538 521 467 586 388 641 303 685 213 719 119 740 24 749 -72 746 -166 731 -259 703 -346 664 -429 615 -504 555 -571 486 -628 409 -675 325 -711 236 -736 143 -748 48 -748 -48 -736 -143 -711 -236 -675 -325 -628 -409 -571 -486 -504 -555 -429 -615 -346 -664 -2...
output:
14376
result:
ok single line: '14376'
Test #49:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
42 1000 0 988 149 955 294 900 433 826 563 733 680 623 781 500 866 365 930 222 974 74 997 -74 997 -222 974 -365 930 -499 866 -623 781 -733 680 -826 563 -900 433 -955 294 -988 149 -1000 0 -988 -149 -955 -294 -900 -433 -826 -563 -733 -680 -623 -781 -500 -866 -365 -930 -222 -974 -74 -997 74 -997 222 -97...
output:
34900
result:
ok single line: '34900'
Test #50:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
33 100 0 98 18 92 37 84 54 72 69 58 81 41 90 23 97 4 99 -14 98 -32 94 -49 86 -65 75 -78 61 -88 45 -95 28 -99 9 -99 -9 -95 -28 -88 -45 -78 -61 -65 -75 -50 -86 -32 -94 -14 -98 4 -99 23 -97 41 -90 58 -81 72 -69 84 -54 92 -37 98 -18
output:
515
result:
ok single line: '515'
Test #51:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
25 500 0 484 124 438 240 364 342 267 422 154 475 31 499 -93 491 -212 452 -318 385 -404 293 -464 184 -496 62 -496 -62 -464 -184 -404 -293 -318 -385 -212 -452 -93 -491 31 -499 154 -475 267 -422 364 -342 438 -240 484 -124
output:
24994
result:
ok single line: '24994'
Test #52:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
19 900 0 851 292 710 552 492 753 220 872 -74 896 -361 824 -609 662 -791 428 -887 148 -887 -148 -791 -428 -609 -662 -361 -824 -74 -896 220 -872 492 -753 710 -552 851 -292
output:
142538
result:
ok single line: '142538'
Test #53:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
7 800 0 498 625 -178 779 -720 347 -720 -347 -178 -779 498 -625
output:
1054757
result:
ok single line: '1054757'
Test #54:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
6 999 0 499 865 -499 865 -999 0 -499 -865 499 -865
output:
2588522
result:
ok single line: '2588522'
Test #55:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 1000 0 309 951 -809 587 -809 -587 309 -951
output:
5311708
result:
ok single line: '5311708'
Test #56:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
4 999 -999 999 -1000 1000 -1000 1000 -999
output:
0
result:
ok single line: '0'
Test #57:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 6 4 5 10 4 13 5 7 6 3
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 -4 6 -10 5 -13 4 -7 5 -3 6
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #59:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
5 -6 -4 -5 -10 -4 -13 -5 -7 -6 -3
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #60:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
5 4 -6 10 -5 13 -4 7 -5 3 -6
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
5 -6 4 -6 3 -5 7 -4 13 -5 10
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5 -4 -6 -3 -6 -7 -5 -13 -4 -10 -5
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5 6 -4 6 -3 5 -7 4 -13 5 -10
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #64:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
5 4 6 3 6 7 5 13 4 10 5
output:
infinitely many
result:
ok single line: 'infinitely many'
Test #65:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
4 -800 -100 -799 -103 -798 -105 -799 -102
output:
0
result:
ok single line: '0'
Test #66:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 602 -59 600 -60 603 -59 605 -58
output:
0
result:
ok single line: '0'
Test #67:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
4 -999 -999 -1000 -999 -1000 -1000 -999 -1000
output:
0
result:
ok single line: '0'
Test #68:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
4 -50 50 -52 51 -51 50 -49 49
output:
0
result:
ok single line: '0'
Test #69:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
4 5 0 6 0 7 1 6 1
output:
0
result:
ok single line: '0'
Test #70:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
4 3 -3 4 -4 5 -4 4 -3
output:
0
result:
ok single line: '0'