QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#694483 | #9520. Concave Hull | daoqi | AC ✓ | 160ms | 17288kb | C++20 | 18.1kb | 2024-10-31 18:03:57 | 2024-10-31 18:03:59 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using l64 = long double;
using l64 = long double;
template<class T>
struct Point {
T x;
T y;
Point(T x_ = 0, T y_ = 0) : x(x_), y(y_) {}
template<class U>
operator Point<U>() {
return Point<U>(U(x), U(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 bool operator<(Point a, Point b) {
return a.x < b.x || (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;
}
};
//角度转弧度
long double change(l64 d) {
return acos(-1.0) / 180 * d;
}
template<class T>
T dot(Point<T> a, Point<T> b) {//计算两个点之间的点积。
return a.x * b.x + a.y * b.y;
}
template<class T>
T cross(Point<T> a, Point<T> b) {//计算两个点之间的叉积
return a.x * b.y - a.y * b.x;
}
template<class T>
T square(Point<T> p) {//计算一个点与其自身的点积
return dot(p, p);
}
template<class T>
double length(Point<T> p) {//计算一个点表示的向量的长度
return std::sqrt(double(square(p)));
}
long double length(Point<long double> p) {
return std::sqrt(square(p));
}
template<class T>
struct Line {
Point<T> a;
Point<T> b;
Line(Point<T> a_ = Point<T>(), Point<T> b_ = Point<T>()) : a(a_), b(b_) {}
friend std::istream &operator>>(std::istream &is, Line &l) {
return is >> l.a.x >> l.a.y >> l.b.x >> l.b.y;
}
};
template<class T>
T dist(Point<T> p, Line<T> line) {// 计算点道线段的距离
if (line.a == line.b) {
return dist(p, line.a);
}
Point<T> p1 = line.b - line.a, p2 = p - line.a, p3 = p - line.b;
if (dot(p1, p2) < 0) return length(p2);
if (dot(p1, p3) > 0) return length(p3);
return fabs(cross(line.b - line.a, p - line.a) / length(line.b - line.a));
}
template<class T>
T dist(Point<T> a, Point<T> b) {//计算两点之间的距离
return std::hypot(a.x - b.x, a.y - b.y);
}
template<class T>
T dist(Line<T> line) {//计算直线的距离
return std::hypot(line.a.x - line.b.x, line.a.y - line.b.y);
}
template<class T>
Point<T> rotate(Point<T> a, l64 d = 90) {//将一个点绕原点旋转 d 度(逆时针)
d = change(d);
return Point(a.x * std::cos(d) - std::sin(d) * a.y, std::sin(d) * a.x + std::cos(d) * a.y);
}
//根据点的位置(相对于原点)返回一个符号值。如果点在 x 轴上方(或在 x 轴上但 y = 0 且 x > 0),则返回 1;否则返回 -1。
template<class T>
int sgn(Point<T> a) {
return a.y > 0 || (a.y == 0 && a.x > 0) ? 1 : -1;
}
template<class T>
bool pointOnLineLeft(Point<T> p, Line<T> l) {//判断点 p 是否在线段 l 的左侧(不包括线段上)。
return cross(l.b - l.a, p - l.a) > 0;
}
template<class T>
Point<T> lineIntersection(Line<T> l1, Line<T> l2) {//计算两条线段 l1 和 l2 的交点。
return l1.a + (l1.b - l1.a) * (cross(l2.b - l2.a, l1.a - l2.a) / cross(l2.b - l2.a, l1.a - l1.b));
}
template<class T>
bool pointOnSegment(Point<T> p, Line<T> l) {//判断点 p 是否在线段 l 上(包括端点)。
return cross(p - l.a, l.b - l.a) == 0 && std::min(l.a.x, l.b.x) <= p.x && p.x <= std::max(l.a.x, l.b.x)
&& std::min(l.a.y, l.b.y) <= p.y && p.y <= std::max(l.a.y, l.b.y);
}
template<class T>
bool pointInPolygon(Point<T> a, std::vector<Point<T>> p) {//判断点 a 是否在多边形 p 内部。
int n = p.size();
for (int i = 0; i < n; i++) {
if (pointOnSegment(a, Line(p[i], p[(i + 1) % n]))) {
return true;
}
}
int t = 0;
for (int i = 0; i < n; i++) {
auto u = p[i];
auto v = p[(i + 1) % n];
if (u.x < a.x && v.x >= a.x && pointOnLineLeft(a, Line(v, u))) {
t ^= 1;
}
if (u.x >= a.x && v.x < a.x && pointOnLineLeft(a, Line(u, v))) {
t ^= 1;
}
}
return t == 1;
}
template<class T>
std::vector<Point<T>> Andrew(std::vector<Point<T>> p) {//求凸包
std::sort(p.begin(), p.end(), [&](Point<T> x, Point<T> y) {
return x.x != y.x ? x.x < y.x : x.y < y.y;
});
if (p.size() <= 2) return p;
std::vector<Point<T>> stk;
int n = p.size();
for (int i = 0; i < n; i++) {
while (stk.size() > 1 && cross(stk.back() - stk[stk.size() - 2], p[i] - stk[stk.size() - 2]) <= 0)
stk.pop_back();
stk.push_back(p[i]);
}
int tmp = stk.size();
for (int i = n - 2; i >= 0; i--) {
while (stk.size() > tmp && cross(stk.back() - stk[stk.size() - 2], p[i] - stk[stk.size() - 2]) <= 0)
stk.pop_back();
stk.push_back(p[i]);
}
stk.pop_back();
return stk;
}
template<class T>
std::pair<Point<T>, Point<T>> rotatingCalipers(std::vector<Point<T>> &p) {//旋转卡壳求最远点对距离
T res = 0;
std::pair<Point<T>, Point<T>> ans;
int n = p.size();
for (int i = 0, j = 1; i < n; i++) {
while (cross(p[i + 1] - p[i], p[j] - p[i]) < cross(p[i + 1] - p[i], p[j + 1] - p[i])) j = (j + 1) % n;
if (square(p[i] - p[j]) > res) {
ans = {p[i], p[j]};
res = square(p[i] - p[j]);
}
if (square(p[i + 1] - p[j]) > res) {
ans = {p[i + 1], p[j]};
res = square(p[i + 1] - p[j]);
}
}
return ans;
}
// 0 : not intersect不相交
// 1 : strictly intersect严格相交
// 2 : overlap重叠
// 3 : intersect at endpoint在端点相交
//判断两条线段 l1 和 l2 是否相交,
template<class T>
std::tuple<int, Point<T>, Point<T>> segmentIntersection(Line<T> l1, Line<T> l2) {
if (std::max(l1.a.x, l1.b.x) < std::min(l2.a.x, l2.b.x)) {
return {0, Point<T>(), Point<T>()};
}
if (std::min(l1.a.x, l1.b.x) > std::max(l2.a.x, l2.b.x)) {
return {0, Point<T>(), Point<T>()};
}
if (std::max(l1.a.y, l1.b.y) < std::min(l2.a.y, l2.b.y)) {
return {0, Point<T>(), Point<T>()};
}
if (std::min(l1.a.y, l1.b.y) > std::max(l2.a.y, l2.b.y)) {
return {0, Point<T>(), Point<T>()};
}
if (cross(l1.b - l1.a, l2.b - l2.a) == 0) {
if (cross(l1.b - l1.a, l2.a - l1.a) != 0) {
return {0, Point<T>(), Point<T>()};
} else {
auto maxx1 = std::max(l1.a.x, l1.b.x);
auto minx1 = std::min(l1.a.x, l1.b.x);
auto maxy1 = std::max(l1.a.y, l1.b.y);
auto miny1 = std::min(l1.a.y, l1.b.y);
auto maxx2 = std::max(l2.a.x, l2.b.x);
auto minx2 = std::min(l2.a.x, l2.b.x);
auto maxy2 = std::max(l2.a.y, l2.b.y);
auto miny2 = std::min(l2.a.y, l2.b.y);
Point<T> p1(std::max(minx1, minx2), std::max(miny1, miny2));
Point<T> p2(std::min(maxx1, maxx2), std::min(maxy1, maxy2));
if (!pointOnSegment(p1, l1)) {
std::swap(p1.y, p2.y);
}
if (p1 == p2) {
return {3, p1, p2};
} else {
return {2, p1, p2};
}
}
}
auto cp1 = cross(l2.a - l1.a, l2.b - l1.a);
auto cp2 = cross(l2.a - l1.b, l2.b - l1.b);
auto cp3 = cross(l1.a - l2.a, l1.b - l2.a);
auto cp4 = cross(l1.a - l2.b, l1.b - l2.b);
if ((cp1 > 0 && cp2 > 0) || (cp1 < 0 && cp2 < 0) || (cp3 > 0 && cp4 > 0) || (cp3 < 0 && cp4 < 0)) {
return {0, Point<T>(), Point<T>()};
}
Point p = lineIntersection(l1, l2);
if (cp1 != 0 && cp2 != 0 && cp3 != 0 && cp4 != 0) {
return {1, p, p};
} else {
return {3, p, p};
}
}
//判断一条线段 l 是否完全位于一个多边形 p 内部
template<class T>
bool segmentInPolygon(Line<T> l, std::vector<Point<T>> p) {
int n = p.size();
if (!pointInPolygon(l.a, p)) {
return false;
}
if (!pointInPolygon(l.b, p)) {
return false;
}
for (int i = 0; i < n; i++) {
auto u = p[i];
auto v = p[(i + 1) % n];
auto w = p[(i + 2) % n];
auto [t, p1, p2] = segmentIntersection(l, Line(u, v));
if (t == 1) {
return false;
}
if (t == 0) {
continue;
}
if (t == 2) {
if (pointOnSegment(v, l) && v != l.a && v != l.b) {
if (cross(v - u, w - v) > 0) {
return false;
}
}
} else {
if (p1 != u && p1 != v) {
if (pointOnLineLeft(l.a, Line(v, u))
|| pointOnLineLeft(l.b, Line(v, u))) {
return false;
}
} else if (p1 == v) {
if (l.a == v) {
if (pointOnLineLeft(u, l)) {
if (pointOnLineLeft(w, l)
&& pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, l)
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
} else if (l.b == v) {
if (pointOnLineLeft(u, Line(l.b, l.a))) {
if (pointOnLineLeft(w, Line(l.b, l.a))
&& pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, Line(l.b, l.a))
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
} else {
if (pointOnLineLeft(u, l)) {
if (pointOnLineLeft(w, Line(l.b, l.a))
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
} else {
if (pointOnLineLeft(w, l)
|| pointOnLineLeft(w, Line(u, v))) {
return false;
}
}
}
}
}
}
return true;
}
template<class T>
std::vector<Point<T>> hp(std::vector<Line<T>> lines) {
std::sort(lines.begin(), lines.end(), [&](auto l1, auto l2) {
auto d1 = l1.b - l1.a;
auto d2 = l2.b - l2.a;
if (sgn(d1) != sgn(d2)) {
return sgn(d1) == 1;
}
return cross(d1, d2) > 0;
});
std::deque<Line<T>> ls;
std::deque<Point<T>> ps;
for (auto l: lines) {
if (ls.empty()) {
ls.push_back(l);
continue;
}
while (!ps.empty() && !pointOnLineLeft(ps.back(), l)) {
ps.pop_back();
ls.pop_back();
}
while (!ps.empty() && !pointOnLineLeft(ps[0], l)) {
ps.pop_front();
ls.pop_front();
}
if (cross(l.b - l.a, ls.back().b - ls.back().a) == 0) {
if (dot(l.b - l.a, ls.back().b - ls.back().a) > 0) {
if (!pointOnLineLeft(ls.back().a, l)) {
assert(ls.size() == 1);
ls[0] = l;
}
continue;
}
return {};
}
ps.push_back(lineIntersection(ls.back(), l));
ls.push_back(l);
}
while (!ps.empty() && !pointOnLineLeft(ps.back(), ls[0])) {
ps.pop_back();
ls.pop_back();
}
if (ls.size() <= 2) {
return {};
}
ps.push_back(lineIntersection(ls[0], ls.back()));
return std::vector(ps.begin(), ps.end());
}
//计算覆盖所有点的矩形的最小面积
template<class T>
T MinRectangeCover(std::vector<Point<T>> P) {
int n = P.size();
if (n < 3) return 0;
P.push_back(P[0]);
T ans = std::numeric_limits<T>::max();
for (int i = 0, r = 1, p = 1, q; i < n; i++) {
while (cross(P[i + 1] - P[i], P[r] - P[i]) < cross(P[i + 1] - P[i], P[r + 1] - P[i])) r = (r + 1) % n;
while (dot(P[i + 1] - P[i], P[p] - P[i]) <= dot(P[i + 1] - P[i], P[p + 1] - P[i])) p = (p + 1) % n;
if (i == 0) q = p;
while (dot(P[i + 1] - P[i], P[q] - P[i]) >= dot(P[i + 1] - P[i], P[q + 1] - P[i])) q = (q + 1) % n;
T d = square(P[i] - P[i + 1]);
T tmp = cross(P[i + 1] - P[i], P[r] - P[i]) / d *
(dot(P[i + 1] - P[i], P[p] - P[i]) - dot(P[i + 1] - P[i], P[q] - P[i]));
if (ans > tmp) ans = tmp;
}
return ans;
}
//计算两个凸包之间的最短距离
template<class T>
T caliper(std::vector<Point<T>> a, std::vector<Point<T>> b) {
auto calc = [&](std::vector<Point<T>> &p1, std::vector<Point<T>> &p2) {
int n = p1.size() - 1, m = p2.size() - 1;
int mn = 0, mx = 0;
for (int i = 0; i < n; i++) if (p1[mn].y > p1[i].y) mn = i;
for (int i = 0; i < m; i++) if (p2[mx].y < p2[i].y) mx = i;
T ans = std::numeric_limits<T>::max();
for (int i = 0; i < n; i++) {
while (cross(p1[mn + 1] - p1[mn], p2[mx + 1] - p1[mn]) > cross(p1[mn + 1] - p1[mn], p2[mx] - p1[mn]))
mx = (mx + 1) % m;
ans = std::min({ans, dist(p1[mn], Line{p2[mx], p2[mx + 1]}), dist(p1[mn + 1], Line{p2[mx], p2[mx + 1]}),
dist(p2[mx], Line{p1[mn], p1[mn + 1]}), dist(p2[mx + 1], Line{p1[mn], p1[mn + 1]})});
mn = (mn + 1) % n;
}
return ans;
};
a.push_back(a[0]);
b.push_back(b[0]);
return std::min(calc(a, b), calc(b, a));
}
//从平面的点组成的三角形面积的最小最大值(n^2log)
template<class T>
std::pair<T, T> minmaxTriangle(std::vector<Point<T>> p) {
if (p.size() <= 2) return {0, 0};
std::vector<std::pair<int, int>> evt;
evt.reserve(p.size() * p.size());
T t = std::abs(cross(p[0] - p[1], p[0] - p[2]));
T min = t, max = t;
for (int i = 0; i < p.size(); i++) {
for (int j = 0; j < p.size(); j++) {
if (i == j || p[i] == p[j]) continue;
evt.emplace_back(i, j);
}
}
auto cmp = [&](Point<T> x, Point<T> y) -> bool {
auto calc = [&](Point<T> tmp) {
if (tmp.y < 0) return 1;
if (tmp.y > 0) return 4;
if (tmp.x < 0) return 5;
if (tmp.x > 0) return 3;
return 2;
};
int t1 = calc(x), t2 = calc(y);
if (t1 != t2) return t1 < t2;
T t = cross(x, y);
return t > 0;
};
std::sort(evt.begin(), evt.end(), [&](auto x, auto y) {
Point<T> du = p[x.second] - p[x.first], dv = p[y.second] - p[y.first];
std::swap(du.x, du.y), std::swap(dv.y, dv.x);
du.x *= -1, dv.x *= -1;
return cmp(du, dv);
});
std::vector<int> vx(p.size()), pos(p.size());
for (int i = 0; i < p.size(); i++) vx[i] = i;
std::sort(vx.begin(), vx.end(), [&](int x, int y) {
return p[x].x == p[y].x ? p[x].y < p[y].y : p[x].x < p[y].x;
});
for (int i = 0; i < vx.size(); i++) pos[vx[i]] = i;
for (auto [u, v]: evt) {
int i = pos[u], j = pos[v];
if (i > j) std::swap(u, v), std::swap(i, j);
Point<T> pu = p[u], pv = p[v];
if (i > 0) min = std::min(min, std::abs(cross(p[vx[i - 1]] - pu, p[vx[i - 1]] - pv)));
if (j < vx.size() - 1) min = std::min(min, std::abs(cross(p[vx[j + 1]] - pu, p[vx[j + 1]] - pv)));
max = std::max({max, std::abs(cross(p[vx[0]] - pu, p[vx[0]] - pv)),
std::abs(cross(p[vx.back()] - pu, p[vx.back()] - pv))});
std::swap(vx[i], vx[j]);
pos[u] = j, pos[v] = i;
}
return {min, max};
}
template<class T>
T PolygonArea(std::vector<Point<T>> p) {
int n = p.size();
if (n < 3) return 0;
T s = p[0].y * (p[n - 1].x - p[1].x);
for (int i = 1; i < n; i++) {
s += p[i].y * (p[i - 1].x - p[(i + 1) % n].x);
}
return std::abs(s / 2);
}
template<class T>
T TriangleArea(Point<T> p1, Point<T> p2, Point<T> p3) {
return std::abs(cross(p2 - p1, p3 - p1) / 2);
}
void solve() {
int n;
std::cin >> n;
std::vector<Point<l64>> p(n), p1;
for (int i = 0; i < n; i++) std::cin >> p[i];
auto po1 = Andrew(p);
l64 ans = PolygonArea(po1);
std::set<Point<l64>> se1(po1.begin(), po1.end());
for (int i = 0; i < n; i++) {
if (se1.count(p[i])) continue;
p1.push_back(p[i]);
}
if (p1.empty()) {
std::cout << -1 << "\n";
return;
}
auto po2 = Andrew(p1);
l64 tmp = 1e18;
n = po1.size();
int m = po2.size();
for (int i = 0, j = 0; i < n; i++) {
while (TriangleArea(po1[i], po1[(i + 1) % n], po2[j]) >
TriangleArea(po1[i], po1[(i + 1) % n], po2[(j + 1) % m]))
j = (j + 1) % m;
tmp = std::min(tmp, TriangleArea(po1[i], po1[(i + 1) % n], po2[j]));
}
ans -= tmp;
i64 res = ans * 2;
std::cout << res << "\n";
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while (T--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
2 6 -2 0 1 -2 5 2 0 4 1 2 3 1 4 0 0 1 0 0 1 1 1
output:
40 -1
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
10 243 -494423502 -591557038 -493438474 -648991734 -493289308 -656152126 -491185085 -661710614 -489063449 -666925265 -464265894 -709944049 -447472922 -737242534 -415977509 -773788538 -394263365 -797285016 -382728841 -807396819 -373481975 -814685302 -368242265 -818267002 -344482838 -833805545 -279398...
output:
2178418010787347715 1826413114144932145 1651687576234220014 1883871859778998985 2119126281997959892 894016174881844630 2271191316922158910 1998643358049669416 1740474221286618711 1168195646932543192
result:
ok 10 lines
Test #3:
score: 0
Accepted
time: 53ms
memory: 3916kb
input:
1000 125 64661186 -13143076 302828013 -185438065 -418713797 -191594241 430218126 -397441626 354327250 -836704374 149668812 -598584998 311305970 66790541 199720625 -592356787 468137 -584752683 258775829 96211747 -358669612 -134890109 -129221188 -998432368 -277309896 -140056561 356901185 420557649 -51...
output:
1986320445246155278 1900093336073022078 1612088392301142476 2012259136539173407 1819942017252118749 1772230185841892196 1164835025329039520 1527446155241140517 1807368432185303666 1236918659444944569 1306839249967484778 1984123720246784099 1868728080720036006 667458140583450322 2127932992585026491 4...
result:
ok 1000 lines
Test #4:
score: 0
Accepted
time: 72ms
memory: 3756kb
input:
10000 9 484630042 51929469 -40468396 -517784096 98214104 -103353239 629244333 -475172587 106398764 153884485 49211709 -44865749 1 10 166321833 -247717657 406208245 668933360 13 548702216 -631976459 37150086 -292461024 707804811 -486185860 239775286 -903166050 10096571 -541890068 686103484 558731937 ...
output:
950319193795831919 1661025342421008544 1285164852091455548 1159924751776806668 1206071151805176722 794021230296144371 699991678992587791 1133990718508584290 1486311831172661605 984875884297072200 1327767982175057345 758247019006396699 1355381234262206155 1139262078529131471 1613462877860621700 12392...
result:
ok 10000 lines
Test #5:
score: 0
Accepted
time: 115ms
memory: 4932kb
input:
100 439 471536154 -312612104 155692036 -937312180 -461624056 -357636609 236656684 -911414873 -288656914 -74788431 -465779694 -381475149 -334197401 -903065737 491513067 -447615916 337664889 -852236281 -281689379 -53519178 -159101704 -920779200 -326159514 -95396204 21868593 -994282736 488425383 -41046...
output:
1973162724053130487 2054612790507830954 1726805687754843724 1699420177872986528 2129388571309147631 2198295137903288810 1697185883164440272 1219697450095721478 2027023581922285255 1674691247127206655 1673105966817209954 2179188692918747442 2146544318743443141 2230356305133660648 1676850321902993764 ...
result:
ok 100 lines
Test #6:
score: 0
Accepted
time: 97ms
memory: 4920kb
input:
100 1362 -467257672 -466669 -467054869 -478108 -466973270 -481776 -466556983 -499770 -466329414 -508693 -466248017 -511805 -466158865 -513786 -466101273 -515035 -465927700 -518748 -465717624 -522106 -465303448 -528127 -465124548 -530726 -464649746 -536693 -464554872 -537799 -464478196 -538680 -46416...
output:
1666097696993497 1791366071767866 1806187278469532 1683419854733713 1685891971828916 1730190225081651 1787048201197565 1850308098208660 1710694884375502 1826363113637639 1816375352374659 2047431269497691 1549806516003854 1829438662895747 1678707854135065 1687423392883819 2121960009997761 16687219538...
result:
ok 100 lines
Test #7:
score: 0
Accepted
time: 61ms
memory: 11988kb
input:
2 62666 -486101704 -505730259 -486101698 -506082699 -486101689 -506111362 -486101682 -506126031 -486101528 -506293759 -486101259 -506556385 -486101196 -506613483 -486101154 -506648604 -486100935 -506831392 -486100631 -507083675 -486100470 -507199151 -486100233 -507368923 -486100193 -507397039 -48609...
output:
2178736946152219010 1825181940245096152
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 146ms
memory: 17288kb
input:
2 100000 301945097 76373292 467957663 -286424714 8245445 -597212507 -474204621 -708828667 184159460 105942538 443435905 -429212625 490658771 -382198656 82512047 -612522436 -228221388 -965890088 394789011 -145801151 -106120174 -528202395 428939626 -194437311 497429477 -527407728 365739746 -114818962 ...
output:
2502889432701099511 2267250485735988121
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 160ms
memory: 17132kb
input:
2 100000 221128057 -975244780 -618765360 -785575858 422567455 -906331476 -988680318 -150037424 -929870145 367887908 -757813541 -652471177 291995621 -956419655 -785381507 619012026 468864522 -883270094 -588416522 808557973 859345881 511394814 988105866 153775152 216931298 -976186873 467050734 8842305...
output:
6283183114882825575 6283183188903854361
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
7 5 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 1 0 -1 0 5 1000000000 1000000000 -1000000000 -1000000000 -2 0 -1 0 1 -1 6 1000000000 1000000000 -1000000000 -1000000000 -3 0 -1 0 0 -1 1 -1 4 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000...
output:
4000000000000000000 7000000000 9000000001 -1 6000000002000000000 7999999998000000000 -1
result:
ok 7 lines
Extra Test:
score: 0
Extra Test Passed