QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#405901#8082. Minimum Euclidean DistanceSy03AC ✓329ms4100kbC++2014.9kb2024-05-06 16:28:022024-05-06 16:28:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-06 16:28:03]
  • 评测
  • 测评结果:AC
  • 用时:329ms
  • 内存:4100kb
  • [2024-05-06 16:28:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)

/**
   ____         ___ _____
  / ___| _   _ / _ \___ /
  \___ \| | | | | | ||_ \
   ___) | |_| | |_| |__) |
  |____/ \__, |\___/____/
         |___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
    for (auto &i : v)
        in >> i;
    return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
    for (auto &i : v)
        out << i << " ";
    return out;
}
bool _output = 0;

#include <bits/stdc++.h>
using namespace std;

typedef double db;
const db EPS = 1e-9;

inline int sign(db a)
{
    return a < -EPS ? -1 : a > EPS;
}

inline int cmp(db a, db b)
{
    return sign(a - b);
}

struct P
{
    db x, y;
    P() {}
    P(db _x, db _y) : x(_x), y(_y) {}
    // 重构加减乘除
    P operator+(P p) { return {x + p.x, y + p.y}; }
    P operator-(P p) { return {x - p.x, y - p.y}; }
    P operator*(db d) { return {x * d, y * d}; }
    P operator/(db d) { return {x / d, y / d}; }

    bool operator<(P p) const
    {
        int c = cmp(x, p.x);
        if (c)
            return c == -1;
        return cmp(y, p.y) == -1;
    }

    bool operator==(P o) const { return cmp(x, o.x) == 0 && cmp(y, o.y) == 0; }

    db dot(P p) { return x * p.x + y * p.y; } // 点积
    db det(P p) { return x * p.y - y * p.x; } // 叉积

    db distTo(P p) { return (*this - p).abs(); }
    db alpha() { return atan2(y, x); }
    void read() { cin >> x >> y; }
    void write() { cout << "(" << x << "," << y << ")" << endl; }
    db abs() { return sqrt(abs2()); }
    db abs2() { return x * x + y * y; }
    P rot90() { return P(-y, x); }
    P unit() { return *this / abs(); }
    int quad() const { return sign(y) == 1 || (sign(y) == 0 && sign(x) >= 0); }
    P rot(db an)
    {
        return {x * cos(an) - y * sin(an), x * sin(an) + y * cos(an)};
    }
};

#define cross(p1, p2, p3) \
    ((p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y))
#define crossOp(p1, p2, p3) sign(cross(p1, p2, p3))

// 直线 p1p2, q1q2 是否恰有一个交点
bool chkLL(P p1, P p2, P q1, P q2)
{
    db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
    return sign(a1 + a2) != 0;
}

// 求直线 p1p2, q1q2 的交点
P isLL(P p1, P p2, P q1, P q2)
{
    db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
    return (p1 * a2 + p2 * a1) / (a1 + a2);
}

// 判断区间 [l1, r1], [l2, r2] 是否相交
bool intersect(db l1, db r1, db l2, db r2)
{
    if (l1 > r1)
        swap(l1, r1);
    if (l2 > r2)
        swap(l2, r2);
    return !(cmp(r1, l2) == -1 || cmp(r2, l1) == -1);
}

// 线段 p1p2, q1q2 相交
bool isSS(P p1, P p2, P q1, P q2)
{
    return intersect(p1.x, p2.x, q1.x, q2.x) &&
           intersect(p1.y, p2.y, q1.y, q2.y) &&
           crossOp(p1, p2, q1) * crossOp(p1, p2, q2) <= 0 &&
           crossOp(q1, q2, p1) * crossOp(q1, q2, p2) <= 0;
}

// 线段 p1p2, q1q2 严格相交
bool isSS_strict(P p1, P p2, P q1, P q2)
{
    return crossOp(p1, p2, q1) * crossOp(p1, p2, q2) < 0 &&
           crossOp(q1, q2, p1) * crossOp(q1, q2, p2) < 0;
}

// m 在 a 和 b 之间
bool isMiddle(db a, db m, db b)
{
    /*if (a > b) swap(a, b);
    return cmp(a, m) <= 0 && cmp(m, b) <= 0;*/
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}

bool isMiddle(P a, P m, P b)
{
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

// 点 p 在线段 p1p2 上
bool onSeg(P p1, P p2, P q)
{
    return crossOp(p1, p2, q) == 0 && isMiddle(p1, q, p2);
}
// q1q2 和 p1p2 的交点 在 p1p2 上?

// 点 p 严格在 p1p2 上
bool onSeg_strict(P p1, P p2, P q)
{
    return crossOp(p1, p2, q) == 0 &&
           sign((q - p1).dot(p1 - p2)) * sign((q - p2).dot(p1 - p2)) < 0;
}

// 求 q 到 直线p1p2 的投影(垂足) ⚠️ : p1 != p2
P proj(P p1, P p2, P q)
{
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(q - p1) / dir.abs2());
}

// 求 q 以 直线p1p2 为轴的反射
P reflect(P p1, P p2, P q)
{
    return proj(p1, p2, q) * 2 - q;
}

// 求 q 到 线段p1p2 的最小距离
db nearest(P p1, P p2, P q)
{
    if (p1 == p2)
        return p1.distTo(q);
    P h = proj(p1, p2, q);
    if (isMiddle(p1, h, p2))
        return q.distTo(h);
    return min(p1.distTo(q), p2.distTo(q));
}

// 求 线段p1p2 与 线段q1q2 的距离
db disSS(P p1, P p2, P q1, P q2)
{
    if (isSS(p1, p2, q1, q2))
        return 0;
    return min(min(nearest(p1, p2, q1), nearest(p1, p2, q2)),
               min(nearest(q1, q2, p1), nearest(q1, q2, p2)));
}

// 极角排序

// sort(p, p + n, [&](P a, P b)
//      {
//     int qa = a.quad(), qb = b.quad();
//     if (qa != qb)
//         return qa < qb;
//     else
//         return sign(a.det(b)) > 0; });

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef double db;
// 求多边形面积
db area(vector<P> ps)
{
    db ret = 0;
    rep(i, 0, ps.size()) ret += ps[i].det(ps[(i + 1) % ps.size()]);
    return ret / 2;
}
// 点包含
int contain(vector<P> ps, P p)
{ // 2:inside,1:on_seg,0:outside
    int n = ps.size(), ret = 0;
    rep(i, 0, n)
    {
        P u = ps[i], v = ps[(i + 1) % n];
        if (onSeg(u, v, p))
            return 1;
        if (cmp(u.y, v.y) <= 0)
            swap(u, v);
        if (cmp(p.y, u.y) > 0 || cmp(p.y, v.y) <= 0)
            continue;
        ret ^= crossOp(p, u, v) > 0;
    }
    return ret * 2;
}
// 严格凸包
vector<P> convexHull(vector<P> ps)
{
    int n = ps.size();
    if (n <= 1)
        return ps;
    sort(ps.begin(), ps.end());
    vector<P> qs(n * 2);
    int k = 0;
    for (int i = 0; i < n; qs[k++] = ps[i++])
        while (k > 1 && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0)
            --k;
    for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--])
        while (k > t && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0)
            --k;
    qs.resize(k - 1);
    return qs;
}

// 不严格凸包
vector<P> convexHullNonStrict(vector<P> ps)
{
    // caution: need to unique the Ps first
    int n = ps.size();
    if (n <= 1)
        return ps;
    sort(ps.begin(), ps.end());
    vector<P> qs(n * 2);
    int k = 0;
    for (int i = 0; i < n; qs[k++] = ps[i++])
        while (k > 1 && crossOp(qs[k - 2], qs[k - 1], ps[i]) < 0)
            --k;
    for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--])
        while (k > t && crossOp(qs[k - 2], qs[k - 1], ps[i]) < 0)
            --k;
    qs.resize(k - 1);
    return qs;
}
// 旋转卡壳
db convexDiameter(vector<P> ps)
{
    int n = ps.size();
    if (n <= 1)
        return 0;
    int is = 0, js = 0;
    rep(k, 1, n) is = ps[k] < ps[is] ? k : is, js = ps[js] < ps[k] ? k : js;
    int i = is, j = js;
    db ret = ps[i].distTo(ps[j]);
    do
    {
        if ((ps[(i + 1) % n] - ps[i]).det(ps[(j + 1) % n] - ps[j]) >= 0)
            (++j) %= n;
        else
            (++i) %= n;
        ret = max(ret, ps[i].distTo(ps[j]));
    } while (i != is || j != js);
    return ret;
}

// 切多边形
vector<P> convexCut(const vector<P> &ps, P q1, P q2)
{
    vector<P> qs;
    int n = ps.size();
    rep(i, 0, n)
    {
        P p1 = ps[i], p2 = ps[(i + 1) % n];
        int d1 = crossOp(q1, q2, p1), d2 = crossOp(q1, q2, p2);
        if (d1 >= 0)
            qs.push_back(p1);
        if (d1 * d2 < 0)
            qs.push_back(isLL(p1, p2, q1, q2));
    }
    return qs;
}

#define rep(i, a, n) for (int i = a; i < n; i++)
const double PI = acos(-1.0);

// 判断两个圆的关系
int type(P o1, db r1, P o2, db r2)
{
    db d = o1.distTo(o2);
    if (cmp(d, r1 + r2) == 1)
        return 4;
    if (cmp(d, r1 + r2) == 0)
        return 3;
    if (cmp(d, abs(r1 - r2)) == 1)
        return 2;
    if (cmp(d, abs(r1 - r2)) == 0)
        return 1;
    return 0;
}
// 圆和线相交
vector<P> isCL(P o, db r, P p1, P p2)
{
    if (cmp(abs((o - p1).det(p2 - p1) / p1.distTo(p2)), r) > 0)
        return {};
    db x = (p1 - o).dot(p2 - p1), y = (p2 - p1).abs2(),
       d = x * x - y * ((p1 - o).abs2() - r * r);
    d = max(d, (db)0.0);
    P m = p1 - (p2 - p1) * (x / y), dr = (p2 - p1) * (sqrt(d) / y);
    return {m - dr, m + dr}; // along dir: p1->p2
}

// 两个圆相交的交点
vector<P> isCC(P o1,
               db r1,
               P o2,
               db r2)
{ // need to check whether two circles are the same
    db d = o1.distTo(o2);
    if (cmp(d, r1 + r2) == 1)
        return {};
    if (cmp(d, abs(r1 - r2)) == -1)
        return {};
    d = min(d, r1 + r2);
    db y = (r1 * r1 + d * d - r2 * r2) / (2 * d), x = sqrt(r1 * r1 - y * y);
    P dr = (o2 - o1).unit();
    P q1 = o1 + dr * y, q2 = dr.rot90() * x;
    return {q1 - q2, q1 + q2}; // along circle 1
}

// 求切线,默认求外公切线,求内公切线的话,r2改成负数,求点到圆的切线,r2改成0
//  extanCC, intanCC : -r2, tanCP : r2 = 0
vector<pair<P, P>> tanCC(P o1, db r1, P o2, db r2)
{
    P d = o2 - o1;
    db dr = r1 - r2, d2 = d.abs2(), h2 = d2 - dr * dr;
    if (sign(d2) == 0 || sign(h2) < 0)
        return {};
    h2 = max((db)0.0, h2);
    vector<pair<P, P>> ret;
    for (db sign : {-1, 1})
    {
        P v = (d * dr + d.rot90() * sqrt(h2) * sign) / d2;
        ret.push_back({o1 + v * r1, o2 + v * r2});
    }
    if (sign(h2) == 0)
        ret.pop_back();
    return ret;
}

db rad(P p1, P p2)
{
    return atan2l(p1.det(p2), p1.dot(p2));
}
// 圆和三角形的面积交
db areaCT(db r, P p1, P p2)
{
    vector<P> is = isCL(P(0, 0), r, p1, p2);
    if (is.empty())
        return r * r * rad(p1, p2) / 2;
    bool b1 = cmp(p1.abs2(), r * r) == 1, b2 = cmp(p2.abs2(), r * r) == 1;
    if (b1 && b2)
    {
        P md = (is[0] + is[1]) / 2;
        if (sign((p1 - md).dot(p2 - md)) <= 0)
            return r * r * (rad(p1, is[0]) + rad(is[1], p2)) / 2 +
                   is[0].det(is[1]) / 2;
        else
            return r * r * rad(p1, p2) / 2;
    }
    if (b1)
        return (r * r * rad(p1, is[0]) + is[0].det(p2)) / 2;
    if (b2)
        return (p1.det(is[1]) + r * r * rad(is[1], p2)) / 2;
    return p1.det(p2) / 2;
}

// 内心
P inCenter(P A, P B, P C)
{
    double a = (B - C).abs(), b = (C - A).abs(), c = (A - B).abs();
    return (A * a + B * b + C * c) / (a + b + c);
}
// 外心
P circumCenter(P a, P b, P c)
{
    P bb = b - a, cc = c - a;
    double db = bb.abs2(), dc = cc.abs2(), d = 2 * bb.det(cc);
    return a - P(bb.y * dc - cc.y * db, cc.x * db - bb.x * dc) / d;
}
// 垂心
P othroCenter(P a, P b, P c)
{
    P ba = b - a, ca = c - a, bc = b - c;
    double Y = ba.y * ca.y * bc.y, A = ca.x * ba.y - ba.x * ca.y,
           x0 = (Y + ca.x * ba.y * b.x - ba.x * ca.y * c.x) / A,
           y0 = -ba.x * (x0 - c.x) / ba.y + ca.y;
    return {x0, y0};
}

// 最小圆覆盖,随机增量法
pair<P, db> min_circle(vector<P> ps)
{
    random_device rd;
    mt19937 rng(rd());
    shuffle(ps.begin(), ps.end(), rng);
    // random_shuffle(ps.begin(), ps.end());
    int n = ps.size();
    P o = ps[0];
    db r = 0;
    rep(i, 1, n) if (o.distTo(ps[i]) > r + EPS)
    {
        o = ps[i], r = 0;
        rep(j, 0, i) if (o.distTo(ps[j]) > r + EPS)
        {
            o = (ps[i] + ps[j]) / 2;
            r = o.distTo(ps[i]);
            rep(k, 0, j) if (o.distTo(ps[k]) > r + EPS)
            {
                o = circumCenter(ps[i], ps[j], ps[k]);
                r = o.distTo(ps[i]);
            }
        }
    }
    return {o, r};
}

db intergal(db x, db y, db r, db L, db R)
{
    return r * r * (R - L) + x * r * (sinl(R) - sinl(L)) +
           y * r * (-cosl(R) + cosl(L));
}

db calc_area_circle(P c, db r, db L, db R)
{
    return intergal(c.x, c.y, r, L, R) / 2;
}

db norm(db x)
{
    while (x < 0)
        x += 2 * PI;
    while (x > 2 * PI)
        x -= 2 * PI;
    return x;
}

// 圆面积并
// const int N = 10010;
// P cs[N];
// db rs[N];

// void work()
// {
//     vector<int> cand = {};
//     rep(i, 0, n)
//     {
//         bool ok = 1;
//         rep(j, 0, n) if (i != j)
//         {
//             if (rs[j] > rs[i] + EPS &&
//                 rs[i] + cs[i].distTo(cs[j]) <= rs[j] + EPS)
//             {
//                 ok = 0;
//                 break;
//             }
//             if (cs[i] == cs[j] && cmp(rs[i], rs[j]) == 0 && j < i)
//             {
//                 ok = 0;
//                 break;
//             }
//         }
//         if (ok)
//             cand.push_back(i);
//     }

//     rep(i, 0, cand.size()) cs[i] = cs[cand[i]], rs[i] = rs[cand[i]];
//     n = cand.size();

//     db area = 0;

//     // work
//     rep(i, 0, n)
//     {
//         vector<pair<db, int>> ev = {{0, 0}, {2 * PI, 0}};

//         int cur = 0;

//         rep(j, 0, n) if (j != i)
//         {
//             auto ret = isCC(cs[i], rs[i], cs[j], rs[j]);
//             if (!ret.empty())
//             {
//                 db l = (ret[0] - cs[i]).alpha();
//                 db r = (ret[1] - cs[i]).alpha();
//                 l = norm(l);
//                 r = norm(r);
//                 ev.push_back({l, 1});
//                 ev.push_back({r, -1});
//                 if (l > r)
//                     ++cur;
//             }
//         }

//         sort(ev.begin(), ev.end());
//         rep(j, 0, ev.size() - 1)
//         {
//             cur += ev[j].second;
//             if (cur == 0)
//             {
//                 area += calc_area_circle(cs[i], rs[i], ev[j].fi, ev[j + 1].fi);
//             }
//         }
//     }
// }

void solve()
{
    int n, q;
    cin >> n >> q;
    vector<P> ps;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        ps.push_back({x, y});
    }
    auto cv = convexHull(ps);
    n = cv.size();
    cout << fixed << setprecision(10);
    while (q--)
    {
        P a, b;
        cin >> a.x >> a.y >> b.x >> b.y;
        P c = (a + b) / 2;
        auto r = a.distTo(b) / 2;
        db ans = 0;
        ans += .5 * r * r;
        if (contain(cv, c))
        {
            cout << ans << endl;
            continue;
        }
        db t = 1e18;
        for (int i = 0; i < n; i++)
        {
            auto p1 = cv[i], p2 = cv[(i + 1) % n];
            t = min(t, nearest(p1, p2, c));
        }
        ans += t * t;
        cout << ans << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    if (_output)
        cin >> _;
    while (_--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3832kb

input:

4 3
0 0
1 0
1 1
0 1
0 0 1 1
1 1 2 2
1 1 2 3

output:

0.2500000000
0.7500000000
1.8750000000

result:

ok Your answer is acceptable!^ ^

Test #2:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

48 10
-30 0
-29 -4
-28 -7
-27 -9
-25 -12
-22 -16
-21 -17
-17 -20
-14 -22
-12 -23
-9 -24
-5 -25
-4 -25
0 -24
3 -23
5 -22
8 -20
12 -17
13 -16
16 -12
18 -9
19 -7
20 -4
21 0
21 1
20 5
19 8
18 10
16 13
13 17
12 18
8 21
5 23
3 24
0 25
-4 26
-5 26
-9 25
-12 24
-14 23
-17 21
-21 18
-22 17
-25 13
-27 10
-28 ...

output:

589.5000000000
51.4705882353
1051.2500000000
66.6250000000
174.1250000000
562.6750000000
272.3942307692
287.3850000000
689.6250000000
436.2500000000

result:

ok Your answer is acceptable!^ ^

Test #3:

score: 0
Accepted
time: 277ms
memory: 4080kb

input:

5000 5000
-50000000 0
-49999885 -49450
-49999770 -85675
-49999604 -122394
-49999391 -157604
-49999130 -192731
-49998803 -229143
-49998399 -267196
-49997956 -303872
-49997469 -339362
-49996891 -377221
-49996257 -414903
-49995577 -451819
-49994843 -488600
-49994059 -524941
-49993173 -563137
-49992252 ...

output:

2214785369560633.0000000000
1632645104370924.5000000000
3954739966640761.0000000000
5405105667896786.0000000000
817274719687553.1250000000
902260846427661.1250000000
3194363161448624.0000000000
1619744446324385.0000000000
363457485421825.1875000000
4776425533214309.0000000000
8267595460255074.000000...

result:

ok Your answer is acceptable!^ ^

Test #4:

score: 0
Accepted
time: 148ms
memory: 4008kb

input:

2224 5000
-500000 0
-499999 -30
-499998 -59
-499997 -87
-499996 -114
-499995 -140
-499994 -165
-499993 -189
-499992 -212
-499991 -234
-499990 -255
-499989 -275
-499988 -294
-499987 -312
-499986 -329
-499985 -345
-499984 -360
-499982 -389
-499981 -403
-499979 -430
-499978 -443
-499976 -468
-499975 -4...

output:

931340796015.3750000000
410570465847.7500000000
225774975043.7500000000
686588110927.3748779297
803635163394.8750000000
440321806244.7500000000
781364862674.5000000000
303496624306.7500000000
146653887864.7500000000
1361017661096.7497558594
409649028457.5000000000
417747460932.7500000000
46509181005...

result:

ok Your answer is acceptable!^ ^

Test #5:

score: 0
Accepted
time: 171ms
memory: 4020kb

input:

4672 5000
-300 0
-299 -43
-298 -85
-297 -126
-296 -166
-295 -205
-294 -243
-293 -280
-292 -316
-291 -351
-290 -385
-289 -418
-288 -450
-287 -481
-286 -511
-285 -540
-284 -568
-283 -595
-282 -621
-281 -646
-280 -670
-279 -693
-278 -715
-276 -758
-275 -779
-273 -820
-272 -840
-270 -879
-269 -898
-267 ...

output:

356616.5000000000
121018.5000000000
0.2500000000
189.6250000000
103099.6250000000
83253.1250000000
131701.2500000000
58352.5000000000
355863.1250000000
197638.8597240473
605772.4121621621
2062.4458977408
113763.2500000000
134694.5000000000
74679.6520547945
114481.2500000000
60577.2500000000
7456.250...

result:

ok Your answer is acceptable!^ ^

Test #6:

score: 0
Accepted
time: 29ms
memory: 3956kb

input:

576 5000
-300 0
-299 -15
-298 -29
-297 -42
-296 -54
-295 -65
-294 -75
-293 -84
-292 -92
-290 -107
-289 -114
-287 -127
-286 -133
-284 -144
-283 -149
-280 -163
-278 -172
-275 -185
-274 -189
-270 -204
-267 -215
-265 -222
-262 -232
-258 -245
-257 -248
-252 -262
-248 -273
-245 -281
-240 -294
-238 -299
-2...

output:

189295.2500000000
377943.2944162437
299473.0000000000
243821.9171974522
559270.9922279792
100367.5923396675
472743.1249999999
374450.6249999999
77260.6250000000
106891.2307692308
193578.1250000000
98895.0654145078
124020.0000000000
296138.8749999999
1209.1250000000
480040.6250000000
133543.970689655...

result:

ok Your answer is acceptable!^ ^

Test #7:

score: 0
Accepted
time: 8ms
memory: 3840kb

input:

336 5000
-300 0
-299 -11
-298 -21
-297 -30
-296 -38
-295 -45
-294 -51
-292 -62
-291 -67
-289 -76
-288 -80
-285 -91
-283 -98
-280 -108
-279 -111
-275 -122
-272 -130
-270 -135
-267 -142
-263 -151
-258 -162
-257 -164
-251 -175
-246 -184
-242 -191
-239 -196
-234 -204
-227 -215
-225 -218
-218 -228
-213 -...

output:

478.1250000000
408.1250000000
1341.2500000000
861.2500000000
4210.0000000000
1709.1250000000
846.2500000000
1389.1250000000
722.5000000000
753.1250000000
574.2500000000
1167.1250000000
439.6250000000
5650.2500000000
619.6250000000
2664.5000000000
2138.6250000000
2138.6250000000
1226.2500000000
1226....

result:

ok Your answer is acceptable!^ ^

Test #8:

score: 0
Accepted
time: 13ms
memory: 3884kb

input:

336 5000
-300 0
-299 -11
-298 -21
-297 -30
-296 -38
-295 -45
-294 -51
-292 -62
-291 -67
-289 -76
-288 -80
-285 -91
-283 -98
-280 -108
-279 -111
-275 -122
-272 -130
-270 -135
-267 -142
-263 -151
-258 -162
-257 -164
-251 -175
-246 -184
-242 -191
-239 -196
-234 -204
-227 -215
-225 -218
-218 -228
-213 -...

output:

95.1250000000
8382.6250000000
77361.1250000000
142408.1250000000
98056.2500000000
110581.2500000000
20413.0000000000
1253.1250000000
64468.6250000000
8915.6250000000
93179.1250000000
26286.2500000000
35118.2500000000
129681.2500000000
59545.6250000000
49997.9103773585
1685.1250000000
58020.625000000...

result:

ok Your answer is acceptable!^ ^

Test #9:

score: 0
Accepted
time: 329ms
memory: 3996kb

input:

5000 5000
-50000000 0
-49999912 -33572
-49999824 -59400
-49999710 -83347
-49999578 -105149
-49999382 -130924
-49999166 -154591
-49998916 -178069
-49998599 -203894
-49998262 -228398
-49997905 -251647
-49997466 -277451
-49997003 -302413
-49996511 -326907
-49995964 -352128
-49995393 -376671
-49994795 -...

output:

481990667522174144.0000000000
900047257776892032.0000000000
84250235108292080.0000000000
357963472278544256.0000000000
758024710210129280.0000000000
651805790712522752.0000000000
422072215223185856.0000000000
571948904059660544.0000000000
685946954834849920.0000000000
781017527404628096.0000000000
3...

result:

ok Your answer is acceptable!^ ^

Test #10:

score: 0
Accepted
time: 327ms
memory: 4100kb

input:

5000 5000
-50000000 0
-49999762 -138397
-49999461 -244153
-49999007 -349713
-49998392 -456086
-49997577 -566637
-49996632 -673023
-49995462 -784273
-49994137 -894156
-49992625 -1005080
-49990945 -1115094
-49989066 -1226720
-49987021 -1337531
-49984788 -1449227
-49982415 -1559155
-49979887 -1668061
-...

output:

259053256470500416.0000000000
472297859897907072.0000000000
271976522374482752.0000000000
930648882061706112.0000000000
110596174224097024.0000000000
385963660067947136.0000000000
441658538323309440.0000000000
259108189662189408.0000000000
379723545376251136.0000000000
43293951022380792.0000000000
2...

result:

ok Your answer is acceptable!^ ^

Extra Test:

score: 0
Extra Test Passed