QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#544980#7521. Find the GapasitshouldbeAC ✓53ms4684kbC++1740.0kb2024-09-02 21:24:382024-09-02 21:24:38

Judging History

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

  • [2024-09-02 21:24:38]
  • 评测
  • 测评结果:AC
  • 用时:53ms
  • 内存:4684kb
  • [2024-09-02 21:24:38]
  • 提交

answer

#include <bits/stdc++.h>
#define pi acos(-1.0)
// #define double long double
using namespace std;
const double eps = 1e-8, inf = 1e12;
const int N = 1e4 + 10;
int sgn(double x)
{
    if (fabs(x) < eps) return 0;
    if (x < 0) return -1;
    else return 1;
}
int dsgn(double x, double y)
{
    if (fabs(x - y) < eps) return 0;
    if (x < y) return -1;
    else return 1;
}
inline double sqr(double x) { return x * x; }

struct Point
{
    double x, y;
    Point() {}
    Point(double _x, double _y) { x = _x;y = _y; }
    void input() { cin >> x >> y; }
    bool operator==(Point b) const { return sgn(x - b.x) == 0 && sgn(y - b.y) == 0; }
    bool operator<(Point b) const { return sgn(x - b.x) == 0 ? sgn(y - b.y) < 0 : x < b.x; }
    Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }
    Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }
    // 叉积
    double operator^(const Point &b) const { return x * b.y - y * b.x; }
    // 点积
    double operator*(const Point &b) const { return x * b.x + y * b.y; }
    // 数乘
    Point operator*(const double &k) const {return Point(x * k, y * k);}
    Point operator/(const double &k) const { return Point(x / k, y / k);}
    // 返回长度
    double len() { return hypot(x, y); }
    // 返回长度的平方
    double len2() { return x * x + y * y; }
    // 返回两点的距离
    double distance(Point p) { return hypot(x - p.x, y - p.y); }
    int distance2(Point p) { return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y); }
    //`计算pa  和  pb 的夹角 就是求这个点看a,b 所成的夹角`
    //`测试 LightOJ1203`
    double rad(Point a, Point b)
    {
        Point p = *this;
        return fabs(atan2(fabs((a - p) ^ (b - p)), (a - p) * (b - p)));
    }
    //`绕着p点逆时针旋转angle`
    Point rotate(Point p, double angle)
    {
        Point v = (*this) - p;
        double c = cos(angle), s = sin(angle);
        return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
    }
    //`化为长度为r的向量`
    Point trunc(double r)
    {
        double l = len();
        if (!sgn(l)) return *this;
        r /= l;
        return Point(x * r, y * r);
    }
    //`逆时针旋转90度`
    Point rotleft() { return Point(-y, x); }
    //`顺时针旋转90度`;
    Point rotright() { return Point(y, -x); }
};
//`AB X AC`
double cross(Point A, Point B, Point C) { return (B - A) ^ (C - A); }
//`AB*AC`
double dot(Point A, Point B, Point C) { return (B - A) * (C - A); }
struct Line
{
    Point s, e;
    Line() {}
    Line(Point _s, Point _e) { s = _s;e = _e; }
    bool operator==(Line v) { return (s == v.s) && (e == v.e); }
    //`根据一个点和倾斜角angle确定直线,0<=angle<pi`
    Line(Point p, double angle)
    {
        s = p;
        if (sgn(angle - pi / 2) == 0) e = (s + Point(0, 1));
        else e = (s + Point(1, tan(angle)));
    }
    // ax+by+c=0
    Line(double a, double b, double c)
    {
        if (sgn(a) == 0)
        {
            s = Point(0, -c / b);
            e = Point(1, -c / b);
        }
        else if (sgn(b) == 0)
        {
            s = Point(-c / a, 0);
            e = Point(-c / a, 1);
        }
        else
        {
            s = Point(0, -c / b);
            e = Point(1, (-c - a) / b);
        }
    }
    void input() { s.input();e.input(); }
    void adjust() { if (e < s) swap(s, e); }
    // 求线段长度
    double length() { return s.distance(e); }
    //`返回直线倾斜角 0<=angle<pi`
    double angle()
    {
        double k = atan2(e.y - s.y, e.x - s.x);
        // if(sgn(k) < 0)k += pi;
        // if(sgn(k-pi) == 0)k -= pi;
        return k;
    }
    bool operator<(Line &v) { return sgn(angle() - v.angle()) == 0 ? ((e - s) ^ (v.e - s)) < 0 : angle() < v.angle(); }
    //`点和直线关系`
    int relation(Point p)
    {
        int c = sgn((p - s) ^ (e - s));
        if (c < 0) return 1;      //`1  在左侧`
        else if (c > 0) return 2; //`2  在右侧`
        else return 3;            //`3  在直线上`
    }
    //`点在线段上的判断`
    bool pointonseg(Point p) { return sgn((p - s) ^ (e - s)) == 0 && sgn((p - s) * (p - e)) <= 0; }
    //`两向量平行(对应直线平行或重合)`
    bool parallel(Line v) { return sgn((e - s) ^ (v.e - v.s)) == 0; }
    //`两向量正交`
    bool orthogonal(Line v) { return sgn((e - s) * (v.e - v.s)) == 0; }
    //`两直线关系`
    int linecrossline(Line v)
    {
        if ((*this).parallel(v))             //`0 平行`
            return v.relation(s) == 3;       //`1 重合`
        if ((*this).orthogonal(v)) return 3; //`3 正交`
        else return 2;                       //`2 相交`
    }
    //`两线段相交判断`
    int segcrossseg(Line v)
    {
        int d1 = sgn((e - s) ^ (v.s - s));
        int d2 = sgn((e - s) ^ (v.e - s));
        int d3 = sgn((v.e - v.s) ^ (s - v.s));
        int d4 = sgn((v.e - v.s) ^ (e - v.s));
        if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;      //`2 规范相交`
        return (d1 == 0 && sgn((v.s - s) * (v.s - e)) <= 0) || //`1 非规范相交`
               (d2 == 0 && sgn((v.e - s) * (v.e - e)) <= 0) || //`0 不相交`
               (d3 == 0 && sgn((s - v.s) * (s - v.e)) <= 0) ||
               (d4 == 0 && sgn((e - v.s) * (e - v.e)) <= 0);
    }
    //`直线和线段相交判断`
    int linecrossseg(Line v)
    {
        int d1 = sgn((e - s) ^ (v.s - s));
        int d2 = sgn((e - s) ^ (v.e - s));
        if ((d1 ^ d2) == -2) return 2;     //`2 规范相交`
        return (d1 == 0 || d2 == 0);       //`1 非规范相交 0 不相交`
    }
    //`求两直线的交点  要保证两直线不平行或重合`
    Point crosspoint(Line l)
    {
        Point u = e - s, v = l.e - l.s;
        double t = (s - l.s) ^ v / (v ^ u);
        return s + u * t;
    }
    //`返回点p在直线上的投影`
    Point lineprog(Point p)
    {
        Point u = e - s, v = p - s;
        return s + u * (u * v / u.len2());
    }
    // 点到直线的距离
    double dispointtoline(Point p) { return fabs((p - s) ^ (e - s)) / length(); }
    // 点到线段的距离
    double dispointtoseg(Point p)
    {
        if (sgn((p - s) * (e - s)) < 0 || sgn((p - e) * (s - e)) < 0)
            return min(p.distance(s), p.distance(e));
        return dispointtoline(p);
    }
    //`返回线段到线段的距离 前提是两线段不相交,相交距离就是0了`
    double dissegtoseg(Line v)
    {
        return min(min(dispointtoseg(v.s), dispointtoseg(v.e)), min(v.dispointtoseg(s), v.dispointtoseg(e)));
    }
    //`返回点p关于直线的对称点`
    Point symmetrypoint(Point p)
    {
        Point pro = lineprog(p);
        return pro * 2 - p;
    }
};

struct circle
{
    Point p;  // 圆心
    double r; // 半径
    circle() {}
    circle(Point _p, double _r) { p = _p;r = _r; }
    circle(double x, double y, double _r) { p = Point(x, y);r = _r; }
    //`三角形的外接圆`
    //`需要Point的+ /  rotate()  以及Line的crosspoint()`
    //`利用两条边的中垂线得到圆心`
    //`测试:UVA12304`
    circle(Point a, Point b, Point c)
    {
        Line u = Line((a + b) / 2, ((a + b) / 2) + ((b - a).rotleft()));
        Line v = Line((b + c) / 2, ((b + c) / 2) + ((c - b).rotleft()));
        p = u.crosspoint(v);
        r = p.distance(a);
    }
    //`三角形的内切圆`
    //`参数bool t没有作用,只是为了和上面外接圆函数区别`
    //`测试:UVA12304`
    circle(Point a, Point b, Point c, bool t)
    {
        Line u, v;
        double m = atan2(b.y - a.y, b.x - a.x), n = atan2(c.y - a.y, c.x - a.x);
        u.s = a;
        u.e = u.s + Point(cos((n + m) / 2), sin((n + m) / 2));
        v.s = b;
        m = atan2(a.y - b.y, a.x - b.x), n = atan2(c.y - b.y, c.x - b.x);
        v.e = v.s + Point(cos((n + m) / 2), sin((n + m) / 2));
        p = u.crosspoint(v);
        r = Line(a, b).dispointtoseg(p);
    }
    // 输入
    void input() { p.input();cin >> r; }
    bool operator==(circle v) { return (p == v.p) && sgn(r - v.r) == 0; }
    bool operator<(circle v) const { return ((p < v.p) || ((p == v.p) && sgn(r - v.r) < 0)); }
    // 面积
    double area() { return pi * r * r; }
    // 周长
    double circumference() { return 2 * pi * r; }
    //`点和圆的关系`
    int relation(Point b)
    {
        double dst = b.distance(p);
        if (sgn(dst - r) < 0) return 2;       //`2 圆内`
        else if (sgn(dst - r) == 0) return 1; //`1 圆上`
        return 0;                             //`0 圆外`
    }
    //`线段和圆的关系 比较的是圆心到线段的距离和半径的关系`
    int relationseg(Line v)
    {
        double dst = v.dispointtoseg(p);
        if (sgn(dst - r) < 0) return 2;       //`2 相交`
        else if (sgn(dst - r) == 0) return 1; //`1 相切`
        return 0;                             //`0 相离`
    }
    //`直线和圆的关系 比较的是圆心到直线的距离和半径的关系`
    int relationline(Line v)
    {
        double dst = v.dispointtoline(p);
        if (sgn(dst - r) < 0) return 2;       //`2 相交`
        else if (sgn(dst - r) == 0) return 1; //`1 相切`
        return 0;                             //`0 相离`
    }
    //`两圆的关系 需要Point的distance`
    //`测试:UVA12304`
    int relationcircle(circle v)
    {
        double d = p.distance(v.p);
        if (sgn(d - r - v.r) > 0) return 5;                   //`5 相离`
        if (sgn(d - r - v.r) == 0) return 4;                  //`4 外切`
        double l = fabs(r - v.r);
        if (sgn(d - r - v.r) < 0 && sgn(d - l) > 0) return 3; //`3 相交`
        if (sgn(d - l) == 0) return 2;                        //`2 内切`
        if (sgn(d - l) < 0) return 1;                         //`1 内含`
    }
    //`求两个圆的交点 需要relationcircle`
    //`测试:UVA12304`
    int pointcrosscircle(circle v, Point &p1, Point &p2)
    {
        int rel = relationcircle(v);
        if (rel == 1 || rel == 5) return 0;               //`0 无交点`
        double d = p.distance(v.p);
        double l = (d * d + r * r - v.r * v.r) / (2 * d);
        double h = sqrt(r * r - l * l);
        Point tmp = p + (v.p - p).trunc(l);
        p1 = tmp + ((v.p - p).rotleft().trunc(h));
        p2 = tmp + ((v.p - p).rotright().trunc(h));
        if (rel == 2 || rel == 4) return 1;               //`1 一个交点`
        return 2;                                         //`2 两个交点`
    }
    //`求直线和圆的交点,返回交点个数`
    int pointcrossline(Line v, Point &p1, Point &p2)
    {
        if (!(*this).relationline(v)) return 0;
        Point a = v.lineprog(p);
        double d = v.dispointtoline(p);
        d = sqrt(r * r - d * d);
        if (sgn(d) == 0)
        {
            p1 = a;
            p2 = a;
            return 1;
        }
        p1 = a + (v.e - v.s).trunc(d);
        p2 = a - (v.e - v.s).trunc(d);
        return 2;
    }
    //`得到过a,b两点,半径为r1的两个圆`
    int gercircle(Point a, Point b, double r1, circle &c1, circle &c2)
    {
        circle x(a, r1), y(b, r1);
        int t = x.pointcrosscircle(y, c1.p, c2.p);
        if (!t) return 0;
        c1.r = c2.r = r;
        return t; //`返回圆的个数`
    }
    //`得到与直线u相切,过点q,半径为r1的圆`
    //`测试:UVA12304`
    int getcircle(Line u, Point q, double r1, circle &c1, circle &c2)
    {
        double dis = u.dispointtoline(q);
        if (sgn(dis - r1 * 2) > 0) return 0;
        if (sgn(dis) == 0)
        {
            c1.p = q + ((u.e - u.s).rotleft().trunc(r1));
            c2.p = q + ((u.e - u.s).rotright().trunc(r1));
            c1.r = c2.r = r1;
            return 2;
        }
        Line u1 = Line((u.s + (u.e - u.s).rotleft().trunc(r1)), (u.e + (u.e - u.s).rotleft().trunc(r1)));
        Line u2 = Line((u.s + (u.e - u.s).rotright().trunc(r1)), (u.e + (u.e - u.s).rotright().trunc(r1)));
        circle cc = circle(q, r1);
        Point p1, p2;
        if (!cc.pointcrossline(u1, p1, p2)) cc.pointcrossline(u2, p1, p2);
        c1 = circle(p1, r1);
        if (p1 == p2)
        {
            c2 = c1;
            return 1;
        }
        c2 = circle(p2, r1);
        return 2;
    }
    //`同时与直线u,v相切,半径为r1的圆`
    //`测试:UVA12304`
    int getcircle(Line u, Line v, double r1, circle &c1, circle &c2, circle &c3, circle &c4)
    {
        if (u.parallel(v)) return 0; // 两直线平行
        Line u1 = Line(u.s + (u.e - u.s).rotleft().trunc(r1), u.e + (u.e - u.s).rotleft().trunc(r1));
        Line u2 = Line(u.s + (u.e - u.s).rotright().trunc(r1), u.e + (u.e - u.s).rotright().trunc(r1));
        Line v1 = Line(v.s + (v.e - v.s).rotleft().trunc(r1), v.e + (v.e - v.s).rotleft().trunc(r1));
        Line v2 = Line(v.s + (v.e - v.s).rotright().trunc(r1), v.e + (v.e - v.s).rotright().trunc(r1));
        c1.r = c2.r = c3.r = c4.r = r1;
        c1.p = u1.crosspoint(v1);
        c2.p = u1.crosspoint(v2);
        c3.p = u2.crosspoint(v1);
        c4.p = u2.crosspoint(v2);
        return 4;
    }
    //`同时与不相交圆cx,cy相切,半径为r1的圆`
    //`测试:UVA12304`
    int getcircle(circle cx, circle cy, double r1, circle &c1, circle &c2)
    {
        circle x(cx.p, r1 + cx.r), y(cy.p, r1 + cy.r);
        int t = x.pointcrosscircle(y, c1.p, c2.p);
        if (!t) return 0;
        c1.r = c2.r = r1;
        return t; //`返回圆的个数`
    }
    //`过一点作圆的切线(先判断点和圆的关系)`
    //`测试:UVA12304`
    int tangentline(Point q, Line &u, Line &v)
    {
        int x = relation(q);
        if (x == 2)  return 0;
        if (x == 1)
        {
            u = Line(q, q + (q - p).rotleft());
            v = u;
            return 1;
        }
        double d = p.distance(q);
        double l = r * r / d;
        double h = sqrt(r * r - l * l);
        u = Line(q, p + ((q - p).trunc(l) + (q - p).rotleft().trunc(h)));
        v = Line(q, p + ((q - p).trunc(l) + (q - p).rotright().trunc(h)));
        return 2; //`返回切线的个数`
    }
    int tangentpoint(Point q, Point &u, Point &v)
    {
        int x = relation(q);
        if (x == 2) return 0;
        if (x == 1)
        {
            u = q;
            v = u;
            return 1;
        }
        double d = p.distance(q);
        double l = r * r / d;
        double h = sqrt(r * r - l * l);
        u = p + ((q - p).trunc(l) + (q - p).rotleft().trunc(h));
        v = p + ((q - p).trunc(l) + (q - p).rotright().trunc(h));
        return 2; //`返回切点的个数`
    }
    //`求两圆相交的面积`
    double areacircle(circle v)
    {
        int rel = relationcircle(v);
        if (rel >= 4) return 0.0;
        if (rel <= 2) return min(area(), v.area());
        double d = p.distance(v.p);
        double hf = (r + v.r + d) / 2.0;
        double ss = 2 * sqrt(hf * (hf - r) * (hf - v.r) * (hf - d));
        double a1 = acos((r * r + d * d - v.r * v.r) / (2.0 * r * d));
        a1 = a1 * r * r;
        double a2 = acos((v.r * v.r + d * d - r * r) / (2.0 * v.r * d));
        a2 = a2 * v.r * v.r;
        return a1 + a2 - ss;
    }
    //`求圆和三角形pab的相交面积`
    //`测试:POJ3675 HDU3982 HDU2892`
    double areatriangle(Point a, Point b)
    {
        if (sgn((p - a) ^ (p - b)) == 0) return 0.0;
        Point q[5],p1, p2;
        int len = 0;
        q[len++] = a;
        Line l(a, b);
        if (pointcrossline(l, q[1], q[2]) == 2)
        {
            if (sgn((a - q[1]) * (b - q[1])) < 0) q[len++] = q[1];
            if (sgn((a - q[2]) * (b - q[2])) < 0) q[len++] = q[2];
        }
        q[len++] = b;
        if (len == 4 && sgn((q[0] - q[1]) * (q[2] - q[1])) > 0) swap(q[1], q[2]);
        double res = 0;
        for (int i = 0; i < len - 1; i++)
        {
            if (relation(q[i]) == 0 || relation(q[i + 1]) == 0)
            {
                double arg = p.rad(q[i], q[i + 1]);
                res += r * r * arg / 2.0;
            }
            else res += fabs((q[i] - p) ^ (q[i + 1] - p)) / 2.0;
        }
        return res;
    }
    //`两圆公切线`
    Point getpoint(double rad) { return Point(p.x + r * cos(rad), p.y + r * sin(rad)); }
    int conmontangent(circle v, vector<Point> &p1, vector<Point> &p2)
    {
        bool flag = 0;
        if (r < v.r) swap(*this, v), flag = 1;
        double d = p.distance(v.p), rd = r - v.r, rs = r + v.r;
        if (sgn(d - rd) < 0) return 0;
        if (sgn(d) == 0) return -1;
        double rad = Line(p, v.p).angle();
        if (sgn(d - rd) == 0)
        {
            p1.push_back(getpoint(rad)), p2.push_back(getpoint(rad));
            return 1; //`一条外公切线`
        }
        double rad1 = acos(rd / d);
        p1.push_back(getpoint(rad + rad1)), p2.push_back(v.getpoint(rad + rad1));
        p1.push_back(getpoint(rad - rad1)), p2.push_back(v.getpoint(rad - rad1));
        if (sgn(d - rs) == 0)
        {
            p1.push_back(getpoint(rad)), p2.push_back(getpoint(rad));
            if (flag) swap(p1, p2);
            return 3; //`两条外公切线 一条内公切线`
        }
        else if (sgn(d - rs) > 0)
        {
            double rad2 = acos(rs / d);
            p1.push_back(getpoint(rad + rad2)), p2.push_back(v.getpoint(rad + rad2 - pi));
            p1.push_back(getpoint(rad - rad2)), p2.push_back(v.getpoint(rad - rad2 + pi));
            if (flag) swap(p1, p2);
            return 4; //`两条外公切线 两条内公切线`
        }
        else
        {
            if (flag) swap(p1, p2);
            return 2; //`两条外公切线`
        }
    }
};

struct polygon
{
    int n;
    Point p[N];
    Line l[N];
    void input(int _n)
    {
        n = _n;
        for (int i = 0; i < n; i++) p[i].input();
    }
    void add(Point q) { p[n++] = q; }
    void getline()
    {
        for (int i = 0; i < n; i++)
            l[i] = Line(p[i], p[(i + 1) % n]);
    }
    struct cmp
    {
        Point p;
        cmp(const Point &p0) { p = p0; }
        bool operator()(const Point &aa, const Point &bb)
        {
            Point a = aa, b = bb;
            int d = sgn((a - p) ^ (b - p));
            if (d == 0) return sgn(a.distance(p) - b.distance(p)) < 0;
            return d > 0;
        }
    };
    //`进行极角排序 mi为极点`
    //`需要重载号好Point的 < 操作符(min函数要用) `
    void norm(Point mi)
    {
        // Point mi = p[0];
        // for(int i = 1;i < n;i++)mi = min(mi,p[i]);
        sort(p, p + n, cmp(mi));
    }
    //`得到的凸包里面的点编号是0-n-1的`
    //`注意如果有影响,要特判下所有点共点,或者共线的特殊情况`
    //`测试 LightOJ1203  LightOJ1239`
    void andrew(polygon &convex)
    {
        sort(p, p + n);
        int &top = convex.n;
        top = 0;
        for (int i = 0; i < n; i++)
        {
            while (top >= 2 && sgn(cross(convex.p[top - 2], convex.p[top - 1], p[i])) <= 0) top--;
            convex.p[top++] = p[i];
        }
        int temp = top;
        for (int i = n - 2; i >= 0; i--)
        {
            while (top > temp && sgn(cross(convex.p[top - 2], convex.p[top - 1], p[i])) <= 0) top--;
            convex.p[top++] = p[i];
        }
        top--;
    }
    //`判断是不是凸的`
    bool isconvex()
    {
        bool s[5];
        memset(s, false, sizeof(s));
        for (int i = 0; i < n; i++)
        {
            int j = (i + 1) % n, k = (j + 1) % n;
            s[sgn((p[j] - p[i]) ^ (p[k] - p[i])) + 1] = true;
            if (s[0] && s[2]) return false;
        }
        return true;
    }
    //`判断点和任意多边形的关系`
    int relationpoint(Point q)
    {
        for (int i = 0; i < n; i++)
            if (p[i] == q) return 3;                 //` 3 点上`
        for (int i = 0; i < n; i++)
            if (l[i].pointonseg(q)) return 2;        //` 2 边上`
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            int j = (i + 1) % n;
            int k = sgn((q - p[j]) ^ (p[i] - p[j]));
            int u = sgn(p[i].y - q.y);
            int v = sgn(p[j].y - q.y);
            if (k > 0 && u < 0 && v >= 0) cnt++;
            if (k < 0 && v < 0 && u >= 0) cnt--;
        }                                            //` 1 内部`
        return cnt != 0;                             //` 0 外部`
    }
    //`直线u切割凸多边形左侧 注意直线方向`
    //`测试:HDU3982`
    void convexcut(Line u, polygon &po)
    {
        int &top = po.n; // 注意引用
        top = 0;
        for (int i = 0; i < n; i++)
        {
            int d1 = sgn((u.e - u.s) ^ (p[i] - u.s));
            int d2 = sgn((u.e - u.s) ^ (p[(i + 1) % n] - u.s));
            if (d1 >= 0) po.p[top++] = p[i];
            if (d1 * d2 < 0) po.p[top++] = u.crosspoint(Line(p[i], p[(i + 1) % n]));
        }
    }
    //`得到周长`
    //`测试 LightOJ1239`
    double getcircumference()
    {
        double sum = 0;
        for (int i = 0; i < n; i++)
            sum += p[i].distance(p[(i + 1) % n]);
        return sum;
    }
    //`得到面积`
    double getarea()
    {
        double sum = 0;
        for (int i = 0; i < n; i++)
            sum += (p[i] ^ p[(i + 1) % n]);
        return fabs(sum) / 2;
    }
    //`得到方向`
    bool getdir()
    {
        double sum = 0;
        for (int i = 0; i < n; i++)
            sum += (p[i] ^ p[(i + 1) % n]);
        if (sgn(sum) > 0) return 1; //` 1 逆时针`
        else return 0;              //` 0 顺时针`
    }
    //`得到重心`
    Point getbarycentre()
    {
        Point ret(0, 0);
        double area = 0;
        for (int i = 1; i < n - 1; i++)
        {
            double tmp = (p[i] - p[0]) ^ (p[i + 1] - p[0]);
            if (sgn(tmp) == 0) continue;
            area += tmp;
            ret.x += (p[0].x + p[i].x + p[i + 1].x) / 3 * tmp;
            ret.y += (p[0].y + p[i].y + p[i + 1].y) / 3 * tmp;
        }
        if (sgn(area)) ret = ret / area;
        return ret;
    }
    //`多边形和圆交的面积`
    //`测试:POJ3675 HDU3982 HDU2892`
    double areacircle(circle c)
    {
        double ans = 0;
        for (int i = 0; i < n; i++)
        {
            int j = (i + 1) % n;
            if (sgn((p[j] - c.p) ^ (p[i] - c.p)) >= 0) ans += c.areatriangle(p[i], p[j]);
            else ans -= c.areatriangle(p[i], p[j]);
        }
        return fabs(ans);
    }
    //`多边形和圆关系`
    int relationcircle(circle c)
    {
        int x = 2;                                  //` 2 圆完全在多边形内`
        if (relationpoint(c.p) != 1) return 0;      //` 0 圆心不在内部`
        for (int i = 0; i < n; i++)
        {
            if (c.relationseg(l[i]) == 2) return 0; //` 0 其它`
            if (c.relationseg(l[i]) == 1) x = 1;    //` 1 圆在多边形里面,碰到了多边形边界`
        }
        return x;
    }
    //`旋转卡壳求凸包直径(最远点对)`
    double rorating_calipers1()
    {
        double res = 0;
        for (int i = 0, j = 1; i < n; i++)
        {
            while (dsgn(cross(p[i], p[i + 1], p[j]), cross(p[i], p[i + 1], p[j + 1])) < 0) j = (j + 1) % n;
            res = max(res, max(p[i].distance(p[j]), p[i + 1].distance(p[j])));
        }
        return res;
    }
    //`旋转卡壳求最小矩形覆盖`
    double rorating_calipers2(polygon &pt)
    {
        double res = 1e20;
        for (int i = 0, a = 1, b = 1, c; i < n; i++)
        {
            while (dsgn(cross(p[i], p[i + 1], p[a]), cross(p[i], p[i + 1], p[a + 1])) < 0) a = (a + 1) % n;
            while (dsgn(dot(p[i], p[i + 1], p[b]), dot(p[i], p[i + 1], p[b + 1])) < 0) b = (b + 1) % n;
            if (!i) c = a;
            while (dsgn(dot(p[i + 1], p[i], p[c]), dot(p[i + 1], p[i], p[c + 1])) < 0) c = (c + 1) % n;
            double d = p[i].distance(p[i + 1]);
            double H = cross(p[i], p[i + 1], p[a]) / d;
            double R = dot(p[i], p[i + 1], p[b]) / d;
            double L = dot(p[i + 1], p[i], p[c]) / d;
            if (dsgn(res, (L + R - d) * H) > 0)
            {
                res = (L + R - d) * H;
                pt.p[0] = p[i + 1] + (p[i] - p[i + 1]) * (L / d);
                pt.p[1] = p[i] + (p[i + 1] - p[i]) * (R / d);
                pt.p[2] = pt.p[1] + (p[i + 1] - p[i]).rotleft() * (H / d);
                pt.p[3] = pt.p[0] + (p[i + 1] - p[i]).rotleft() * (H / d);
            }
        }
        return res;
    }
    //`分治法求最近点对`
    Point a[N];
    double divide(int l, int r)
    {
        if (l == r) return 2e9;
        if (l + 1 == r) return p[l].distance(p[r]);
        int mid = l + r >> 1;
        double d = min(divide(l, mid), divide(mid + 1, r));
        int k = 0;
        for (int i = l; i <= r; i++)
            if (fabs(p[mid].x - p[i].x) < d) a[k++] = p[i];
        // sort(a,a+k,[&](Point a,Point b)->bool {return a.y<b.y;});
        for (int i = 0; i < k; i++)
            for (int j = i + 1; j < k && a[j].y - a[i].y < d; j++)
                d = min(d, a[j].distance(a[i]));
        return d;
    }
    //`旋转卡壳求最大三角形面积`
    double rotating_calipers3()
    {
        double res = 0;
        for (int i = 0; i < n; i++)
        {
            int k = i + 1;
            for (int j = i + 1; j < n; j++)
            {
                while (dsgn(cross(p[i], p[j], p[k]), cross(p[i], p[j], p[k + 1])) < 0) k = (k + 1) % n;
                res = max(res, cross(p[i], p[j], p[k]));
            }
        }
        return res / 2;
    }
};
//`半平面交求凸多边形面积交`
double half_plane1(Line l[], int n)
{
    double res = 0;
    sort(l, l + n);
    Line q[N];
    Point p[N];
    int h = 0, t = 0, k = 0;
    q[t++] = l[0];
    for (int i = 1; i < n; i++)
    {
        if (sgn(l[i].angle() - l[i - 1].angle()) == 0) continue;
        while (h < t - 1 && l[i].relation(q[t - 1].crosspoint(q[t - 2])) == 2) t--;
        while (h < t - 1 && l[i].relation(q[h].crosspoint(q[h + 1])) == 2) h++;
        q[t++] = l[i];
    }
    while (h < t - 1 && l[h].relation(q[t - 1].crosspoint(q[t - 2])) == 2) t--;
    q[t++] = q[h];
    for (int i = h; i < t - 1; i++) p[k++] = q[i].crosspoint(q[i + 1]);
    for (int i = 1; i < k - 1; i++) res += (p[i] - p[0]) ^ (p[i + 1] - p[0]);
    return res / 2;
}
//`水平可见直线 从上向下看输出能看见哪些直线`
void half_plane2(Line l[], int n)
{
    sort(l, l + n);
    Line q[N];
    int h = 0, t = 0, k = 0;
    q[t++] = l[0];
    for (int i = 1; i < n; i++)
    {
        if (sgn(l[i].angle() - l[i - 1].angle()) == 0) continue;
        while (h < t - 1 && l[i].relation(q[t - 1].crosspoint(q[t - 2])) == 2) t--;
        // while(h<t-1&&l[i].relation(q[h].crosspoint(q[h+1]))==2) h++;
        q[t++] = l[i];
    }
    int ans[N];
    for (int i = h; i < t; i++)
        // for(auto j:q[i].id) ans[k++]=j;
    sort(ans, ans + k);
    cout << k << endl;
    for (int i = 0; i < k; i++) cout << ans[i] << " ";
}
//`多边形内核`
bool half_plane3(Line l[], int n)
{
    sort(l, l + n);
    Line q[N];
    int h = 0, t = 0;
    q[t++] = l[0];
    for (int i = 1; i < n; i++)
    {
        if (sgn(l[i].angle() - l[i - 1].angle()) == 0) continue;
        while (h < t - 1 && l[i].relation(q[t - 1].crosspoint(q[t - 2])) == 2) t--;
        while (h < t - 1 && l[i].relation(q[h].crosspoint(q[h + 1])) == 2) h++;
        q[t++] = l[i];
    }
    while (h < t - 1 && l[h].relation(q[t - 1].crosspoint(q[t - 2])) == 2) t--;
    return t - h >= 3;
}
//`最小圆覆盖`
circle increment(Point p[], int n)
{
    random_shuffle(p, p + n);
    circle ans;
    ans.p = p[0], ans.r = 0;
    for (int i = 1; i < n; i++)
        if (ans.r < ans.p.distance(p[i]))
        {
            ans.p = p[i], ans.r = 0;
            for (int j = 0; j < i; j++)
                if (ans.r < ans.p.distance(p[j]))
                {
                    ans.p = (p[i] + p[j]) / 2, ans.r = p[i].distance(p[j]) / 2;
                    for (int k = 0; k < j; k++)
                        if (ans.r < ans.p.distance(p[k]))
                        {
                            Point p1 = (p[i] + p[j]) / 2;
                            Point v1 = (p[i] - p[j]).rotright();
                            Point p2 = (p[i] + p[k]) / 2;
                            Point v2 = (p[i] - p[k]).rotright();
                            ans.p = Line(p1, p1 + v1).crosspoint(Line(p2, p2 + v2));
                            ans.r = ans.p.distance(p[i]);
                        }
                }
        }
    return ans;
}
//`自适应辛普森积分`
inline double f(double x)
{ // 积分函数
    return x;
}
double simpson(double l, double r)
{ // 辛普森公式
    double mid = (l + r) / 2;
    return (r - l) * (f(l) + f(r) + 4 * f(mid)) / 6;
}
double asr(double l, double r, double ans)
{ // 自适应
    double mid = (l + r) / 2;
    double a = simpson(l, mid), b = simpson(mid, r);
    if (sgn(a + b - ans) == 0) return ans;
    return asr(l, mid, a) + asr(mid, r, b);
}

struct Point3
{
    double x, y, z;
    //Point3(){}
    Point3(double _x=0, double _y=0, double _z=0) { x = _x;y = _y;z = _z; }
    void input() { cin>>x>>y>>z; }
    bool operator==(const Point3 &b) const {return sgn(x-b.x)==0&&sgn(y-b.y)==0&&sgn(z-b.z)==0;}
    bool operator<(const Point3 &b) const {return sgn(x-b.x)==0?(sgn(y-b.y)==0?sgn(z-b.z)<0:y<b.y):x<b.x;}
    double len() { return sqrt(x * x + y * y + z * z); }
    double len2() { return x * x + y * y + z * z; }
    double distance(const Point3 &b) const {return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y)+(z-b.z)*(z-b.z));}
    Point3 operator-(const Point3 &b) const { return Point3(x - b.x, y - b.y, z - b.z); }
    Point3 operator+(const Point3 &b) const { return Point3(x + b.x, y + b.y, z + b.z); }
    Point3 operator*(const double &k) const { return Point3(x * k, y * k, z * k); }
    Point3 operator/(const double &k) const { return Point3(x / k, y / k, z / k); }
    // 点乘
    double operator*(const Point3 &b) const { return x * b.x + y * b.y + z * b.z; }
    // 叉乘
    Point3 operator^(const Point3 &b) const {return Point3(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);}
    double rad(Point3 a, Point3 b)
    {
        Point3 p = (*this);
        return acos(((a - p) * (b - p)) / (a.distance(p) * b.distance(p)));
    }
    //`化为长度为r的向量`
    Point3 trunc(double r)
    {
        double l = len();
        if (!sgn(l)) return *this;
        r /= l;
        return Point3(x * r, y * r, z * r);
    }
};

struct Line3
{
    Point3 s, e;
    Line3() {}
    Line3(Point3 _s, Point3 _e) { s = _s;e = _e; }
    bool operator==(const Line3 v) { return (s == v.s) && (e == v.e); }
    void input() { s.input();e.input(); }
    double length() { return s.distance(e); }
    // 点到直线距离
    double dispointtoline(Point3 p) { return ((e - s) ^ (p - s)).len() / s.distance(e); }
    // 点到线段距离
    double dispointtoseg(Point3 p)
    {
        if (sgn((p - s) * (e - s)) < 0 || sgn((p - e) * (s - e)) < 0) return min(p.distance(s), e.distance(p));
        return dispointtoline(p);
    }
    //`返回点p在直线上的投影`
    Point3 lineprog(Point3 p) { return s + (((e - s) * ((e - s) * (p - s))) / ((e - s).len2())); }
    //`p绕此向量逆时针arg角度`
    Point3 rotate(Point3 p, double ang)
    {
        if (sgn(((s - p) ^ (e - p)).len()) == 0) return p;
        Point3 f1 = (e - s) ^ (p - s);
        Point3 f2 = (e - s) ^ (f1);
        double len = ((s - p) ^ (e - p)).len() / s.distance(e);
        f1 = f1.trunc(len);
        f2 = f2.trunc(len);
        Point3 h = p + f2;
        Point3 pp = h + f1;
        return h + ((p - h) * cos(ang)) + ((pp - h) * sin(ang));
    }
    //`点在直线上`
    bool pointonseg(Point3 p) { return sgn(((s - p) ^ (e - p)).len()) == 0 && sgn((s - p) * (e - p)) == 0; }
};

struct Plane
{
    Point3 a, b, c, o; //`平面上的三个点,以及法向量`
    Plane() {}
    Plane(Point3 _a, Point3 _b, Point3 _c)
    {
        a = _a;b = _b;c = _c;
        o = pvec();
    }
    Point3 pvec() { return (b - a) ^ (c - a); }
    //`ax+by+cz+d = 0`
    Plane(double _a, double _b, double _c, double _d)
    {
        o = Point3(_a, _b, _c);
        if (sgn(_a) != 0) a = Point3((-_d - _c - _b) / _a, 1, 1);
        else if (sgn(_b) != 0) a = Point3(1, (-_d - _c - _a) / _b, 1);
        else if (sgn(_c) != 0) a = Point3(1, 1, (-_d - _a - _b) / _c);
    }
    //`点在平面上的判断`
    bool pointonplane(Point3 p) { return sgn((p - a) * o) == 0; }
    //`两平面夹角`
    double angleplane(Plane f) { return acos(o * f.o) / (o.len() * f.o.len()); }
    //`平面和直线的交点,返回值是交点个数`
    int crossline(Line3 u, Point3 &p)
    {
        double x = o * (u.e - a);
        double y = o * (u.s - a);
        double d = x - y;
        if (sgn(d) == 0) return 0;
        p = ((u.s * x) - (u.e * y)) / d;
        return 1;
    }
    //`点到平面最近点(也就是投影)`
    Point3 pointtoplane(Point3 p)
    {
        Line3 u = Line3(p, p + o);
        crossline(u, p);
        return p;
    }
    //`平面和平面的交线`
    int crossplane(Plane f, Line3 &u)
    {
        Point3 oo = o ^ f.o;
        Point3 v = o ^ oo;
        double d = fabs(f.o * v);
        if (sgn(d) == 0) return 0;
        Point3 q = a + (v * (f.o * (f.a - a)) / d);
        u = Line3(q, q + oo);
        return 1;
    }
};

struct CH3D
{
    struct face
    {
        int a, b, c; // 表示凸包一个面上的三个点的编号
        bool ok;     // 表示该面是否属于最终的凸包上的面
    };
    int n;// 初始顶点数
    Point3 P[N];
    int num;// 凸包表面的三角形数
    face F[8 * N];// 凸包表面的三角形
    int g[N][N];
    void input(int _n)
    {
        n = _n;
        for (int i = 0; i < n; i++) P[i].input();
    }
    // 叉乘
    Point3 cross(const Point3 &a, const Point3 &b, const Point3 &c) { return (b - a) ^ (c - a); }
    //`三角形面积*2`
    double area(Point3 a, Point3 b, Point3 c) { return ((b - a) ^ (c - a)).len(); }
    //`四面体有向面积*6`
    double volume(Point3 a, Point3 b, Point3 c, Point3 d) { return ((b - a) ^ (c - a)) * (d - a); }
    //`正:点在面同向`
    double dblcmp(Point3 &p, face &f)
    {
        Point3 p1 = P[f.b] - P[f.a];
        Point3 p2 = P[f.c] - P[f.a];
        Point3 p3 = p - P[f.a];
        return (p1 ^ p2) * p3;
    }
    void deal(int p, int a, int b)
    {
        int f = g[a][b];
        face add;
        if (F[f].ok)
        {
            if (dblcmp(P[p], F[f]) > eps) dfs(p, f);
            else
            {
                add.a = b;
                add.b = a;
                add.c = p;
                add.ok = true;
                g[p][b] = g[a][p] = g[b][a] = num;
                F[num++] = add;
            }
        }
    }
    // 递归搜索所有应该从凸包内删除的面
    void dfs(int p, int now)
    {
        F[now].ok = false;
        deal(p, F[now].b, F[now].a);
        deal(p, F[now].c, F[now].b);
        deal(p, F[now].a, F[now].c);
    }
    bool same(int s, int t)
    {
        Point3 &a = P[F[s].a];
        Point3 &b = P[F[s].b];
        Point3 &c = P[F[s].c];
        return fabs(volume(a, b, c, P[F[t].a])) < eps &&
               fabs(volume(a, b, c, P[F[t].b])) < eps &&
               fabs(volume(a, b, c, P[F[t].c])) < eps;
    }
    // 构建三维凸包
    void create()
    {
        num = 0;
        face add;
        //***********************************
        // 此段是为了保证前四个点不共面
        bool flag = true;
        for (int i = 1; i < n; i++)
        {
            if (!(P[0] == P[i]))
            {
                swap(P[1], P[i]);
                flag = false;
                break;
            }
        }
        if (flag) return;
        flag = true;
        for (int i = 2; i < n; i++)
        {
            if (((P[1] - P[0]) ^ (P[i] - P[0])).len() > eps)
            {
                swap(P[2], P[i]);
                flag = false;
                break;
            }
        }
        if (flag)  return;
        flag = true;
        for (int i = 3; i < n; i++)
        {
            if (fabs(((P[1] - P[0]) ^ (P[2] - P[0])) * (P[i] - P[0])) > eps)
            {
                swap(P[3], P[i]);
                flag = false;
                break;
            }
        }
        if (flag) return;
        //**********************************
        for (int i = 0; i < 4; i++)
        {
            add.a = (i + 1) % 4;
            add.b = (i + 2) % 4;
            add.c = (i + 3) % 4;
            add.ok = true;
            if (dblcmp(P[i], add) > 0) swap(add.b, add.c);
            g[add.a][add.b] = g[add.b][add.c] = g[add.c][add.a] = num;
            F[num++] = add;
        }
        for (int i = 4; i < n; i++)
            for (int j = 0; j < num; j++)
                if (F[j].ok && dblcmp(P[i], F[j]) > eps)
                {
                    dfs(i, j);
                    break;
                }
        int tmp = num;
        num = 0;
        for (int i = 0; i < tmp; i++)
            if (F[i].ok) F[num++] = F[i];
    }
    // 表面积
    //`测试:HDU3528`
    double area()
    {
        double res = 0;
        if (n == 3)
        {
            Point3 p = cross(P[0], P[1], P[2]);
            return p.len() / 2;
        }
        for (int i = 0; i < num; i++)
            res += area(P[F[i].a], P[F[i].b], P[F[i].c]);
        return res / 2.0;
    }
    double volume()
    {
        double res = 0;
        Point3 tmp = Point3(0, 0, 0);
        for (int i = 0; i < num; i++)
            res += volume(tmp, P[F[i].a], P[F[i].b], P[F[i].c]);
        return fabs(res / 6);
    }
    // 表面三角形个数
    int triangle() { return num; }
    // 表面多边形个数
    //`测试:HDU3662`
    int polygon()
    {
        int res = 0;
        for (int i = 0; i < num; i++)
        {
            bool flag = true;
            for (int j = 0; j < i; j++)
                if (same(i, j))
                {
                    flag = 0;
                    break;
                }
            res += flag;
        }
        return res;
    }
    // 重心
    //`测试:HDU4273`
    Point3 barycenter()
    {
        Point3 ans = Point3(0, 0, 0);
        Point3 o = Point3(0, 0, 0);
        double all = 0;
        for (int i = 0; i < num; i++)
        {
            double vol = volume(o, P[F[i].a], P[F[i].b], P[F[i].c]);
            ans = ans + (((o + P[F[i].a] + P[F[i].b] + P[F[i].c]) / 4.0) * vol);
            all += vol;
        }
        ans = ans / all;
        return ans;
    }
    // 点到面的距离
    //`测试:HDU4273`
    double ptoface(Point3 p, int i)
    {
        double tmp1 = fabs(volume(P[F[i].a], P[F[i].b], P[F[i].c], p));
        double tmp2 = ((P[F[i].b] - P[F[i].a]) ^ (P[F[i].c] - P[F[i].a])).len();
        return tmp1 / tmp2;
    }
};

void solve()
{
    int n;cin>>n;
    Point3 p[N];
    for(int i=0;i<n;i++) p[i].input();
    Line3 l[N];int cnt=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<i;j++) l[cnt++]=Line3(p[i],p[j]);
    double res=0;
    for(int i=0;i<cnt;i++)
        for(int j=0;j<i;j++)
        {
            Point3 t=(l[i].e-l[i].s)^(l[j].e-l[j].s);
            if(!t.len2()) continue;
            if(!res) res=1e20;
            double minv=1e20,maxv=-1e20;
            for(int k=0;k<n;k++)
            {
                double dis=t*p[k];
                minv=min(minv,dis);
                maxv=max(maxv,dis);
            }
            double tt=(maxv-minv)/t.len();
            res=min(res,tt);
        }
    cout<<fixed<<setprecision(15)<<res;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

output:

1.000000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #2:

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

input:

5
1 1 1
1 2 1
1 1 2
1 2 2
2 1 1

output:

0.707106781186547

result:

ok found '0.707106781', expected '0.707106781', error '0.000000000'

Test #3:

score: 0
Accepted
time: 3ms
memory: 4624kb

input:

50
973 1799 4431
1036 1888 4509
1099 1977 4587
1162 2066 4665
1225 2155 4743
1288 2244 4821
1351 2333 4899
1414 2422 4977
1540 2600 5133
1603 2689 5211
1666 2778 5289
1729 2867 5367
1792 2956 5445
1855 3045 5523
1918 3134 5601
1981 3223 5679
2044 3312 5757
2107 3401 5835
2170 3490 5913
2296 3668 606...

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 4676kb

input:

50
4532 3245 1339
4624 3260 1345
4716 3275 1351
4808 3290 1357
4900 3305 1363
5084 3335 1375
5176 3350 1381
5268 3365 1387
5360 3380 1393
5452 3395 1399
5544 3410 1405
5728 3440 1417
5820 3455 1423
5912 3470 1429
6096 3500 1441
6188 3515 1447
6280 3530 1453
6372 3545 1459
6464 3560 1465
6556 3575 14...

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: 0
Accepted
time: 52ms
memory: 4620kb

input:

50
1 70 7443
1 138 5063
2 109 5971
3 23 8874
3 152 4359
4 59 7507
5 50 7715
5 73 6910
7 25 8376
7 103 5646
8 3 9039
9 83 6132
9 142 4067
10 124 4590
11 140 3923
12 168 2836
13 46 6999
13 84 5669
13 189 1994
13 229 594
15 171 2410
16 94 4998
20 38 6530
20 125 3485
21 78 5023
22 210 296
23 117 3444
25...

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #6:

score: 0
Accepted
time: 53ms
memory: 4564kb

input:

50
1 95 5991
3 22 9019
25 103 5199
25 141 3603
38 103 4952
39 139 3421
59 6 8627
60 48 6844
66 33 7360
107 88 4271
109 188 33
112 177 438
114 107 3340
122 77 4448
123 169 565
127 1 7545
142 161 540
143 70 4343
146 153 800
156 129 1618
162 63 4276
162 150 622
166 93 2940
173 78 3437
180 143 574
189 1...

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #7:

score: 0
Accepted
time: 49ms
memory: 4628kb

input:

50
14 3658 1218
17 32 7984
741 1906 5773
755 8668 1019
834 2386 4591
1306 3866 7044
2304 2895 120
2450 8613 7374
2595 1919 2119
2610 9866 9419
2694 2845 2941
2838 2702 7608
2883 4143 4049
3082 4800 3611
3338 6703 9039
3424 2035 1863
3471 2672 5858
4339 1330 2029
4720 6970 4719
4853 387 5866
5415 975...

output:

9341.565896183969016

result:

ok found '9341.565896184', expected '9341.565896184', error '0.000000000'

Test #8:

score: 0
Accepted
time: 52ms
memory: 4676kb

input:

50
159 8547 6997
489 5655 1694
934 6033 5986
1088 9448 2840
1395 7938 709
2007 7008 9167
2429 7436 2364
2670 7425 7568
2694 7703 9701
2797 9081 2872
2813 1423 1081
3105 5669 4792
3277 4229 8596
3332 8329 1497
3476 1696 448
3738 996 508
4050 3854 1609
4105 9677 5306
4383 5848 5996
4583 3186 9948
4723...

output:

8144.165721648155341

result:

ok found '8144.165721648', expected '8144.165721648', error '0.000000000'

Test #9:

score: 0
Accepted
time: 52ms
memory: 4628kb

input:

50
140 3759 310
325 657 967
337 2969 2340
341 1234 8436
953 3787 949
1137 9272 5791
1597 8518 7711
2642 3171 9590
2808 2188 9307
2932 7143 773
3075 4055 3861
3479 2654 2788
3516 1372 2617
4202 2476 6906
4446 5279 7147
4586 2815 3229
4956 839 7424
5038 5342 8758
5418 8882 6013
5533 4047 3030
5746 498...

output:

9146.897027572013030

result:

ok found '9146.897027572', expected '9146.897027572', error '0.000000000'

Test #10:

score: 0
Accepted
time: 53ms
memory: 4624kb

input:

50
27 8992 3447
97 1870 5176
255 7759 6929
287 8477 8753
424 6928 3781
561 5383 3443
800 5654 5210
812 829 5236
1058 6953 2716
1129 2576 4054
1525 5088 1278
1743 7422 862
2004 2404 6472
2721 5900 258
3024 9464 4959
3027 8887 4260
3344 6066 5823
3715 5789 9796
3814 5999 277
3915 9604 12
4072 663 3333...

output:

9143.915107107794029

result:

ok found '9143.915107108', expected '9143.915107108', error '0.000000000'

Test #11:

score: 0
Accepted
time: 52ms
memory: 4628kb

input:

50
514 6841 888
673 9023 8705
686 4780 9173
742 2761 5439
894 585 5417
894 1436 3585
1433 6876 9685
1728 8358 463
1736 4442 7163
1758 4362 4567
2175 4091 8630
2631 4226 6098
2648 9912 4504
2752 7427 8318
2806 3482 839
3158 6527 3601
3682 4472 5007
3764 3518 942
4096 1948 2138
4116 9501 5003
4122 318...

output:

9169.736297298837599

result:

ok found '9169.736297299', expected '9169.736297299', error '0.000000000'

Test #12:

score: 0
Accepted
time: 52ms
memory: 4680kb

input:

50
169 7924 553
239 9844 8248
244 7970 4414
476 6722 3954
732 477 1641
966 6652 3944
981 2690 6362
1230 3488 921
1372 3614 4691
1395 5858 4433
1452 253 94
1754 6818 6578
1768 4318 6261
1814 7730 593
2189 7047 1844
2539 4933 4531
2882 8069 831
3188 3902 6915
3217 5522 9148
3552 8575 5975
3909 9654 63...

output:

9150.135233080571197

result:

ok found '9150.135233081', expected '9150.135233081', error '0.000000000'

Test #13:

score: 0
Accepted
time: 53ms
memory: 4624kb

input:

50
96 1653 9109
238 3924 6708
484 8684 2909
750 5493 3159
817 1112 3722
909 918 7323
923 3270 4679
963 4055 5335
1059 9040 4043
1083 5006 2224
1225 2043 1082
1257 6421 570
1884 3398 6379
2010 4066 3604
2270 4127 1357
2714 1776 7355
2916 2914 3705
2960 5403 5768
3613 4179 9807
3792 79 6885
3879 5691 ...

output:

8959.815904859939110

result:

ok found '8959.815904860', expected '8959.815904860', error '0.000000000'

Test #14:

score: 0
Accepted
time: 52ms
memory: 4432kb

input:

50
466 4419 3421
491 2907 9714
506 1869 8685
525 7133 5224
896 6803 414
1018 5218 7102
1291 9905 269
1375 3915 9212
1541 6176 2118
1730 3165 4221
2295 589 9786
2311 9068 6251
2651 8939 9186
2867 6164 7925
3140 5988 5013
3296 7112 5300
3381 16 2989
3495 511 7235
3603 8547 7675
3623 8113 8461
3877 810...

output:

9149.769937427714467

result:

ok found '9149.769937428', expected '9149.769937428', error '0.000000000'

Test #15:

score: 0
Accepted
time: 48ms
memory: 4624kb

input:

50
78 4 4902
193 9001 5084
419 4402 642
578 8090 167
584 9616 4407
1533 4560 8566
1686 179 6908
1951 2381 3902
2010 6519 3351
2083 2122 2314
2394 7870 934
2618 9113 1012
2796 3688 4096
2928 7277 9546
3051 3575 6416
3096 3711 3736
3200 6179 1933
3288 8818 9981
3534 8346 2715
3740 8112 1351
3772 6404 ...

output:

8392.805222252225576

result:

ok found '8392.805222252', expected '8392.805222252', error '0.000000000'

Test #16:

score: 0
Accepted
time: 48ms
memory: 4684kb

input:

50
705 6359 9590
709 9583 837
1100 7827 378
1118 5958 5626
1190 2811 3485
1270 1818 6313
1567 9075 1709
1655 2572 4135
1766 951 2003
1870 352 7790
2509 20 2260
2733 1466 7061
2744 3417 6230
2820 4147 5340
3058 9727 4331
3429 7782 3337
3463 9788 5114
4180 5867 2244
4426 3621 3218
4762 3055 4802
4880 ...

output:

8573.352671254600864

result:

ok found '8573.352671255', expected '8573.352671255', error '0.000000000'

Test #17:

score: 0
Accepted
time: 52ms
memory: 4628kb

input:

50
165 8302 5584
700 7675 6720
881 7965 4577
889 1338 8010
1116 1639 795
1186 8218 2543
1217 7776 3846
1430 9843 1018
1454 998 4454
1624 4047 4040
1624 4230 8183
1682 2296 8486
2100 7651 4049
2147 7426 4916
2524 519 5402
2743 51 6480
3284 5924 8050
3330 5196 9459
3517 4263 5230
3624 6365 595
4043 16...

output:

9058.741907740053648

result:

ok found '9058.741907740', expected '9058.741907740', error '0.000000000'

Test #18:

score: 0
Accepted
time: 52ms
memory: 4428kb

input:

50
100 1845 5981
212 8119 8531
272 2837 9427
393 3708 6901
483 121 2429
545 9916 3687
636 9192 6039
1470 8344 6819
1643 6549 7092
1675 2261 8181
1847 7777 6817
2015 8137 940
2305 9959 58
2336 8793 1450
2399 6420 8272
3224 4903 4156
3225 8648 6448
3274 9687 8319
3431 9580 3305
3488 1299 9485
3622 588...

output:

8012.867917721290723

result:

ok found '8012.867917721', expected '8012.867917721', error '0.000000000'

Test #19:

score: 0
Accepted
time: 49ms
memory: 4580kb

input:

50
19 2681 1646
27 1110 5179
338 6651 3754
507 2567 7601
557 2595 480
580 2720 3352
584 937 6894
591 6885 5697
607 2834 2727
667 9502 9812
789 6818 9256
1122 253 5727
1436 7824 2840
1725 3949 3495
1733 297 2443
1901 7810 3668
1962 2763 775
2279 4850 913
2461 2951 2842
2491 8181 7544
2605 6682 3557
2...

output:

9064.927387661638932

result:

ok found '9064.927387662', expected '9064.927387662', error '0.000000000'

Test #20:

score: 0
Accepted
time: 52ms
memory: 4496kb

input:

50
194 7049 1546
264 8020 6837
847 8285 1854
862 5862 4012
904 9367 6797
1575 4158 8361
1835 2084 4014
1850 418 2351
2003 2813 7003
2043 6346 1467
2046 1800 8962
2530 7010 6913
2992 2316 6887
3399 1789 8276
3518 7325 8772
3545 55 1523
3686 1275 9961
4019 1016 5463
4486 7468 3485
4580 1802 8881
4782 ...

output:

8101.741789061708005

result:

ok found '8101.741789062', expected '8101.741789062', error '0.000000000'

Test #21:

score: 0
Accepted
time: 52ms
memory: 4428kb

input:

50
103 6485 4333
511 6113 4211
639 8425 3693
739 7999 8239
808 5095 8775
826 1656 7709
1173 7565 7160
1320 1179 6855
1326 2043 1063
1604 267 6466
1625 6615 6094
1697 6022 77
1851 6269 1588
2138 4521 288
2648 9706 898
2990 2590 1837
3016 4963 4557
3037 3834 5432
3161 6627 3844
3448 9741 2733
3753 137...

output:

9128.598154250803418

result:

ok found '9128.598154251', expected '9128.598154251', error '0.000000000'

Test #22:

score: 0
Accepted
time: 53ms
memory: 4580kb

input:

50
261 4050 3501
264 4793 7406
737 6575 4542
1143 98 723
1453 9810 529
1676 7893 2790
1936 4005 5944
1954 7716 9379
1980 9534 2502
1981 5073 3147
2117 2971 8441
2144 7774 7451
2279 6190 3900
2292 3909 6381
2723 5981 433
2784 7435 9645
2939 1908 8904
3063 3468 7719
3552 6932 890
3563 3953 5582
3899 2...

output:

9066.875957901978836

result:

ok found '9066.875957902', expected '9066.875957902', error '0.000000000'

Test #23:

score: 0
Accepted
time: 52ms
memory: 4684kb

input:

50
124 8775 2089
502 2885 6276
699 9285 7955
880 6499 8738
1293 8478 4996
1294 7009 3514
1314 6660 8895
1583 49 517
2090 7900 446
2711 1216 9700
2792 1533 727
2840 1552 2842
2965 7790 8788
3491 4707 3568
3704 4977 960
3941 1201 6460
4003 4114 5115
4012 2234 9330
4073 6968 5235
4310 6469 6799
4630 59...

output:

8820.250746374549635

result:

ok found '8820.250746375', expected '8820.250746375', error '0.000000000'

Test #24:

score: 0
Accepted
time: 52ms
memory: 4640kb

input:

50
317 4576 3269
526 4973 5972
1295 1304 4839
1508 3932 1994
1959 7684 48
2001 8395 8132
2232 7475 8511
2667 7154 1453
2747 5229 1254
3229 3535 1083
3346 2197 3601
3430 3753 3090
3432 5831 4752
3526 2117 2434
3868 3250 5864
3909 6614 6027
4133 4435 3421
4352 4192 3560
4559 1398 36
4671 3830 7598
476...

output:

8710.103157749863385

result:

ok found '8710.103157750', expected '8710.103157750', error '0.000000000'

Test #25:

score: 0
Accepted
time: 45ms
memory: 4496kb

input:

50
237 1777 4827
439 298 4986
845 3946 3189
891 4118 3219
914 4204 3234
960 4376 3264
1015 722 1293
1029 4634 3309
1069 5704 7228
1080 1878 9626
1121 4978 3369
1144 5064 3384
1213 5322 3429
1236 5408 3444
1259 5494 3459
1305 5666 3489
1328 5752 3504
1397 6010 3549
1420 6096 3564
1535 6526 3639
1581 ...

output:

8321.886649608903099

result:

ok found '8321.886649609', expected '8321.886649609', error '0.000000000'

Test #26:

score: 0
Accepted
time: 32ms
memory: 4620kb

input:

50
1491 6638 6932
2019 8838 4932
2359 1341 7441
3979 7642 8342
4764 4812 3543
4800 4814 613
4813 4890 638
4865 5194 738
4891 5346 788
4904 5422 813
4943 5650 888
4956 5726 913
4982 5878 963
4995 5954 988
5008 6030 1013
5034 6182 1063
5047 6258 1088
5060 6334 1113
5073 6410 1138
5086 6486 1163
5099 6...

output:

7406.071877357875564

result:

ok found '7406.071877358', expected '7406.071877358', error '0.000000000'

Test #27:

score: 0
Accepted
time: 20ms
memory: 4624kb

input:

50
293 8979 6557
651 1626 1890
654 1682 1935
657 1738 1980
663 1850 2070
666 1906 2115
669 1962 2160
675 2074 2250
678 2130 2295
681 2186 2340
687 2298 2430
693 2410 2520
696 2466 2565
720 2914 2925
723 2970 2970
726 3026 3015
735 3194 3150
738 3250 3195
741 3306 3240
753 3530 3420
765 3754 3600
768...

output:

2809.057941775471136

result:

ok found '2809.057941775', expected '2809.057941775', error '0.000000000'

Test #28:

score: 0
Accepted
time: 10ms
memory: 4496kb

input:

50
2805 3371 1430
2848 3397 1465
2977 3475 1570
3106 3553 1675
3149 3579 1710
3235 3631 1780
3278 3657 1815
3364 3709 1885
3450 3761 1955
3493 3787 1990
3579 3839 2060
3708 3917 2165
3794 3969 2235
4095 4151 2480
4181 4203 2550
4353 4307 2690
4439 4359 2760
4568 4437 2865
4697 4515 2970
4783 4567 30...

output:

710.129084106206847

result:

ok found '710.129084106', expected '710.129084106', error '0.000000000'

Test #29:

score: 0
Accepted
time: 3ms
memory: 4624kb

input:

50
3712 669 4937
3844 779 5025
3976 889 5113
4108 999 5201
4174 1054 5245
4240 1109 5289
4306 1164 5333
4372 1219 5377
4438 1274 5421
4570 1384 5509
4636 1439 5553
4648 4162 7960
4702 1494 5597
4768 1549 5641
4834 1604 5685
4900 1659 5729
4966 1714 5773
5098 1824 5861
5230 1934 5949
5296 1989 5993
5...

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #30:

score: 0
Accepted
time: 48ms
memory: 4644kb

input:

50
2 4 9006
3 23 5330
3 46 1029
4 17 6329
4 50 158
5 12 7141
5 22 5271
10 36 2038
13 43 360
16 33 1861
18 15 4981
18 18 4420
19 10 5793
20 3 6979
20 8 6044
21 35 872
23 22 3057
26 26 1940
26 36 70
27 19 3126
29 27 1384
37 23 1148
41 10 3087
49 8 2477
51 18 361
56 4 2364
57 7 1680
64 1 1941
64 8 632
...

output:

8277.700977916718330

result:

ok found '8277.700977917', expected '8277.700977917', error '0.000000000'

Test #31:

score: 0
Accepted
time: 53ms
memory: 4500kb

input:

50
2 156 5164
2 162 4990
2 241 2699
4 321 67
7 205 2963
8 35 7737
8 284 516
9 75 6421
9 248 1404
10 200 2640
10 219 2089
11 27 7501
11 198 2542
12 95 5373
13 186 2578
15 132 3832
16 106 4430
16 161 2835
18 58 5510
20 157 2327
22 113 3291
24 65 4371
26 11 5625
26 96 3160
27 52 4280
27 151 1409
28 28 ...

output:

6600.951986373336695

result:

ok found '6600.951986373', expected '6600.951986373', error '0.000000000'

Test #32:

score: 0
Accepted
time: 49ms
memory: 4660kb

input:

50
1 51 8290
2 17 9300
2 295 404
4 211 2936
5 259 1322
6 262 1148
7 37 8270
7 125 5454
9 137 4914
10 199 2852
12 205 2504
12 222 1960
20 92 5496
21 244 554
22 161 3132
23 77 5742
32 149 2736
33 82 4802
36 120 3352
37 110 3594
37 161 1962
38 113 3420
44 51 4936
47 16 5822
50 65 4020
52 35 4824
52 60 ...

output:

3583.124742137554676

result:

ok found '3583.124742138', expected '3583.124742138', error '0.000000000'

Test #33:

score: 0
Accepted
time: 52ms
memory: 4676kb

input:

50
2 34 3220
10 19 6149
23 16 6655
27 5 8816
78 1 9255
94 7 7949
102 5 8291
106 5 8263
125 29 3354
176 35 1803
201 21 4414
203 23 4002
216 40 528
254 24 3446
270 35 1145
277 1 7862
283 15 5034
288 5 6989
331 24 2907
353 28 1957
367 32 1063
378 16 4170
416 26 1914
419 1 6868
439 33 360
440 4 6124
444...

output:

3469.210018018442497

result:

ok found '3469.210018018', expected '3469.210018018', error '0.000000000'

Test #34:

score: 0
Accepted
time: 52ms
memory: 4564kb

input:

50
8 297 8499
16 1111 4413
28 1196 3964
75 942 5140
190 63 9305
252 308 7956
307 269 8041
346 503 6793
420 119 8565
446 87 8673
515 692 5510
654 1259 2397
723 1003 3539
786 188 7488
822 1402 1346
843 1569 469
844 1352 1552
972 421 5951
1015 1216 1890
1106 681 4383
1121 1117 2173
1134 463 5417
1166 1...

output:

3265.983569011197687

result:

ok found '3265.983569011', expected '3265.983569011', error '0.000000000'

Test #35:

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

input:

1
3 5 7

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #36:

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

input:

2
2 3 3
7 5 10000

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #37:

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

input:

3
1 2 3
2 3 4
3 4 5

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #38:

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

input:

3
1 2 3
7 8 9
100 200 10000

output:

0.000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'