QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770784#6133. MirrorquailtyAC ✓2025ms4680kbC++237.1kb2024-11-22 00:10:092024-11-22 00:10:10

Judging History

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

  • [2024-11-22 00:10:10]
  • 评测
  • 测评结果:AC
  • 用时:2025ms
  • 内存:4680kb
  • [2024-11-22 00:10:09]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

typedef long double db;

const int MAXN=205;
const db maxc=2e2;
const db inf=1e20;
const db eps=1e-9;

int sgn(db x)
{
    if(x>eps)return 1;
    if(x<-eps)return -1;
    return 0;
}

struct Point
{
    db x,y;
    Point(){}
    Point(db _x,db _y):x(_x),y(_y){}
    Point operator + (const Point& t)const { return Point(x+t.x,y+t.y); }
    Point operator - (const Point& t)const { return Point(x-t.x,y-t.y); }
    Point operator * (const db& t)const { return Point(x*t,y*t); }
    Point operator / (const db& t)const { return Point(x/t,y/t); }
    db operator * (const Point& t)const { return x*t.y-y*t.x; }
    db operator ^ (const Point& t)const { return x*t.x+y*t.y; }
    bool operator < (const Point& t)const { return sgn(x-t.x)==0 ? y<t.y : x<t.x; }
    bool operator == (const Point& t)const { return sgn(x-t.x)==0 && sgn(y-t.y)==0; }
    db len()const { return sqrt(x*x+y*y); }
};

struct Line
{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e):s(_s),e(_e){}
    Point reflect(const Point& s)const
    {
        return get_point(get_ratio(s))*2-s;
    }
    vector<Point> operator & (const Line& t)const
    {
        if(sgn((e-s)*(t.e-t.s))==0)return {};
        return {s+(e-s)*(((t.s-s)*(t.e-t.s))/((e-s)*(t.e-t.s)))};
    }
    db get_ratio(const Point& t)const
    {
        return ((t-s)^(e-s))/(e-s).len()/(e-s).len();
    }
    Point get_point(const db& r)const
    {
        return s+(e-s)*r;
    }
};

bool segment_strict_intersect(const Line& a,const Line& b)
{
    return sgn((b.s-a.s)*(a.e-a.s))*sgn((b.e-a.s)*(a.e-a.s))<0
        && sgn((a.s-b.s)*(b.e-b.s))*sgn((a.e-b.s)*(b.e-b.s))<0;
}
bool point_in_segment(const Point& p,const Line& t)
{
    return sgn((p-t.s)*(p-t.e))==0 && sgn((p-t.s)^(p-t.e))<=0;
}
int point_in_polygon(const Point& p,const vector<Point>& poly)
{
    Line l=Line(p,Point(maxc,p.y));
    int cnt=0;
    for(size_t i=0;i<poly.size();i++)
    {
        Line t=Line(poly[i],poly[(i+1)%poly.size()]);
        if(point_in_segment(p,t))return 0;
        if(segment_strict_intersect(l,t))cnt++;
        else if(sgn(t.s.y-t.e.y))
        {
            if(sgn(t.s.y-t.e.y)>0)swap(t.s,t.e);
            if(sgn(t.s.y-p.y)==0 && sgn(t.s.x-p.x)>=0)cnt++;
        }
    }
    return (cnt%2==0 ? 1 : -1);
}
bool segment_intersect_polygon(const Line& l,const vector<Point>& poly)
{
    for(size_t i=0;i<poly.size();i++)
        if(segment_strict_intersect(l,Line(poly[i],poly[(i+1)%poly.size()])))return 1;
    vector<Point> cut{l.s,l.e};
    for(size_t i=0; i<poly.size(); i++)
        if(point_in_segment(poly[i],l))
            cut.push_back(poly[i]);
    sort(cut.begin(),cut.end(),[&](const Point& a, const Point& b) {
        return ((a-b)^(l.e-l.s))<0;
    });
    cut.erase(unique(cut.begin(),cut.end()),cut.end());
    for(size_t i=0; i+1<cut.size(); i++)
        if(point_in_polygon((cut[i]+cut[i+1])/2, poly)<0)return 1;
    return 0;
}

bool visible(const Point& p,const Point& t,const Line& mr,const vector<Point>& poly)
{
    // never move along mirror
    if(point_in_segment(p,mr))return 0;
    // see target straightly
    if(!segment_strict_intersect(Line(p,t),mr) && !segment_intersect_polygon(Line(p,t),poly))return 1;
    // see target through mirror
    if(sgn((p-mr.s)*(mr.e-mr.s))<=0 || sgn((t-mr.s)*(mr.e-mr.s))<=0)return 0;
    auto inter=Line(p,mr.reflect(t))&mr;
    if(inter.empty())return 0;
    Point m=inter.front();
    if(!point_in_segment(m,mr))return 0;
    if(segment_intersect_polygon(Line(p,m),poly))return 0;
    if(segment_intersect_polygon(Line(m,t),poly))return 0;
    return 1;
}
bool visible(const Line& l,const Point& t,const Line& mr,const vector<Point>& poly,const vector<Line>& border)
{
    vector<Point> cut{l.s,l.e};
    for(auto& b : border)
        for(auto& p : l&b)
            if(point_in_segment(p,l))
                cut.push_back(p);
    sort(cut.begin(),cut.end(),[&](const Point& a, const Point& b) {
        return ((a-b)^(l.e-l.s))<0;
    });
    cut.erase(unique(cut.begin(),cut.end()),cut.end());
    for(size_t i=0;i+1<cut.size();i++)
        if(!visible((cut[i]+cut[i+1])/2, t, mr, poly))return 0;
    return 1;
}

db len[MAXN][MAXN];
int ty[MAXN][MAXN];
int build(const Point& s,const Point& t,const Line& mr,const vector<Point>& poly)
{
    Point rs=mr.reflect(s),rt=mr.reflect(t);
    vector<Line> border;
//    border.push_back(mr);
//    for(size_t i=0;i<poly.size();i++)
//        border.emplace_back(poly[i],poly[(i+1)%poly.size()]);
    for(auto& p : poly)
    {
        border.emplace_back(p,s);
        border.emplace_back(p,t);
        border.emplace_back(p,rs);
        border.emplace_back(p,rt);
    }
    border.emplace_back(s,mr.s);
    border.emplace_back(s,mr.e);
    border.emplace_back(t,mr.s);
    border.emplace_back(t,mr.e);
    border.emplace_back(rs,mr.s);
    border.emplace_back(rs,mr.e);
    border.emplace_back(rt,mr.s);
    border.emplace_back(rt,mr.e);
    vector<Point> keys;
    keys.push_back(s);
    keys.push_back(t);
//    keys.push_back(mr.s);
//    keys.push_back(mr.e);
//    for(auto& p : poly)
//        keys.push_back(p);
    for(size_t i=0;i<border.size();i++)
        for(size_t j=i+1;j<border.size();j++)
            for(auto& p : border[i]&border[j])
                if(find(keys.begin(),keys.end(),p)==keys.end())
                    keys.push_back(p);
    int n=keys.size();
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
        {
            Line l=Line(keys[i],keys[j]);
            if(segment_strict_intersect(l,mr) || segment_intersect_polygon(l,poly))
            {
                len[i][j]=len[j][i]=inf;
                continue;
            }
            int c=visible(l,s,mr,poly,border);
            c|=visible(l,t,mr,poly,border)<<1;
            ty[i][j]=ty[j][i]=c;
            len[i][j]=len[j][i]=(keys[i]-keys[j]).len();
        }
    return n;
}

db dis[MAXN];
bool vis[MAXN];
db cal(int n,int c)
{
    for(int i=0;i<n;i++)
        dis[i]=inf,vis[i]=0;
    dis[0]=0;
    for(int _=0;_<n;_++)
    {
        int u=-1;
        for(int i=0;i<n;i++)
        {
            if(vis[i] || dis[i]==inf)continue;
            if(u==-1 || dis[i]<dis[u])u=i;
        }
        if(u<0)break;
        vis[u]=1;
        for(int v=0;v<n;v++)
        {
            if(vis[v] || (ty[u][v]&c)!=c)continue;
            dis[v]=min(dis[v],dis[u]+len[u][v]);
        }
    }
    return dis[1];
}

int solve()
{
    int m;
    scanf("%d",&m);
    Point s,t;
    scanf("%Lf%Lf%Lf%Lf",&s.x,&s.y,&t.x,&t.y);
    Line mr;
    scanf("%Lf%Lf%Lf%Lf",&mr.s.x,&mr.s.y,&mr.e.x,&mr.e.y);
    vector<Point> poly;
    for(int i=0;i<3;i++)
    {
        db x,y;
        scanf("%Lf%Lf",&x,&y);
        poly.emplace_back(x,y);
    }
    int n=build(s,t,mr,poly);
    db res=0;
    if(m==1)res=cal(n,0);
    else res=cal(n,1)+cal(n,2)+(2*m-3)*cal(n,3);
    if(res<inf)printf("%.12Lf\n",res);
    else printf("-1\n");
    return 0;
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 40ms
memory: 4420kb

input:

2
2
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 -1 3
0 1
-3 -2
3 -2

output:

13.416407864999
-1

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 264ms
memory: 4440kb

input:

25
1
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
100000
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 -1 3
0 1
-3 -2
3 -2
2
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
1
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
2
2 2 -2 2
3 3 -3 3
0 1
-3 -2
3 -2
2
0 0 4 0
0 2 4 2
1 1
3 1
2 -1
1
0 0 4 0
0 2 4...

output:

4.472135955000
13.416407864999
894422.718863960879
-1
-1
4.472135955000
12.000000000000
14.485281374239
4.472135955000
24.142135623731
6.472135955000
-1
8.261297173761
24.910407814435
41.559518455108
7.496976092671
34.702238339670
61.907500586668
7.496976092671
26.397277191929
45.108268355347
63.819...

result:

ok 25 numbers

Test #3:

score: 0
Accepted
time: 130ms
memory: 4376kb

input:

10
1
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
100000
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 -1 3
0 1
-3 -2
3 -2
2
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
1
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
2
2 2 -2 2
3 3 -3 3
0 1
-3 -2
3 -2
2
0 0 4 0
0 2 4 2
1 1
3 1
2 -1
1
0 0 4 0
0 2 4...

output:

4.472135955000
13.416407864999
894422.718863960879
-1
-1
4.472135955000
12.000000000000
14.485281374239
4.472135955000
24.142135623731

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 114ms
memory: 4588kb

input:

10
1
0 0 4 4
0 2 4 2
10 -9
20 0
10 -10
100
0 0 4 4
0 2 4 2
10 -9
20 0
10 -10
1
-2 -2 6 -4
-2 0 2 0
0 -3
3 -3
3 -6
2
-2 -2 6 -4
-2 0 2 0
0 -3
3 -3
3 -6
3
-2 -2 6 -4
-2 0 2 0
0 -3
3 -3
3 -6
1
-4 -8 3 -6
-3 0 0 0
0 -2
2 -7
-2 -7
2
-4 -8 3 -6
-3 0 0 0
0 -2
2 -7
-2 -7
3
-4 -8 3 -6
-3 0 0 0
0 -2
2 -7
-2 -...

output:

6.472135955000
-1
8.261297173761
24.910407814435
41.559518455108
7.496976092671
34.702238339670
61.907500586668
7.496976092671
26.397277191929

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 44ms
memory: 4320kb

input:

10
3
-4 -8 3 -6
0 0 3 0
2 -7
2 -5
1 -3
4
-4 -8 3 -6
0 0 3 0
2 -7
2 -5
1 -3
555
0 -2 0 2
-2 0 2 0
10 10
10 9
9 10
555
0 -2 0 2
2 0 -2 0
10 10
10 9
9 10
1
0 -2 0 2
-2 0 2 0
10 10
10 9
9 10
30
-40 -80 30 -60
0 0 30 0
20 -70
20 -50
10 -30
40
-40 -80 30 -60
0 0 30 0
20 -70
20 -50
10 -30
5550
0 -20 0 20
-...

output:

45.108268355347
63.819259518765
-1
-1
5.656854249492
5503.050297676296
7374.149414018083
-1
-1
-1

result:

ok 10 numbers

Test #6:

score: 0
Accepted
time: 130ms
memory: 4664kb

input:

10
10
-20 0 20 0
-30 30 30 30
0 10
-30 -20
30 -20
20
-20 0 20 0
-30 30 30 30
0 10
-30 -20
30 -20
1000000
-20 0 20 0
-30 30 30 30
0 10
-30 -20
30 -20
20
-20 0 20 0
-30 30 -10 30
0 10
-30 -20
30 -20
20
20 0 -20 0
30 30 -30 30
0 10
-30 -20
30 -20
10
20 0 -20 0
30 30 -30 30
0 10
-30 -20
30 -20
20
20 20 ...

output:

849.705831449920
1744.133022449836
89442674.378632037864
-1
-1
-1
1560.000000000000
1883.086578651014
917.401153701776
2848.772003600252

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 114ms
memory: 4300kb

input:

10
10
0 0 40 40
0 20 40 20
50 -45
100 0
50 -50
1000
0 0 40 40
0 20 40 20
50 -45
100 0
50 -50
10
-20 -20 60 -40
-20 0 20 0
0 -30
30 -30
30 -60
20
-20 -20 60 -40
-20 0 20 0
0 -30
30 -30
30 -60
30
-20 -20 60 -40
-20 0 20 0
0 -30
30 -30
30 -60
10
-40 -80 30 -60
-30 0 0 0
0 -20
20 -70
-20 -70
20
-40 -80 ...

output:

-1
-1
1581.032929398228
3245.943993465580
4910.855057532932
2523.443363156584
5243.969587856441
7964.495812556298
1760.852064992721
3631.951181334509

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 201ms
memory: 4464kb

input:

10
2
-59 -40 -99 8
-7 -51 -61 -60
-75 -51
-51 14
-10 -1
2
46 8 26 -16
-34 34 87 5
42 -43
66 -31
71 -30
2
31 100 6 1
-94 11 -63 81
-98 -53
-81 -51
70 -69
1
72 -74 -69 -61
-55 -58 90 83
32 -62
32 -20
25 -10
88
93 75 52 4
-86 91 -77 17
61 100
-49 -74
93 61
92
-57 36 -6 -66
-13 43 3 -64
-43 -63
-56 -13
...

output:

-1
93.722996110880
306.323358560852
141.598022585063
-1
-1
-1
17.204650534085
10356.723902856540
264.221497989849

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 178ms
memory: 4332kb

input:

10
1
-59 -40 -99 8
-7 -51 -61 -60
-75 -51
-51 14
-10 -1
1
46 8 26 -16
-34 34 87 5
42 -43
66 -31
71 -30
1
31 100 6 1
-94 11 -63 81
-98 -53
-81 -51
70 -69
1
72 -74 -69 -61
-55 -58 90 83
32 -62
32 -20
25 -10
1
93 75 52 4
-86 91 -77 17
61 100
-49 -74
93 61
1
-61 39 97 -47
-34 2 12 -65
86 45
-18 7
67 -58...

output:

83.111071596124
31.240998703627
102.107786186951
141.598022585063
84.213958726168
192.555083133001
115.586091580062
98.005101908013
129.968825191819
145.499140890934

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 178ms
memory: 4336kb

input:

10
2
-59 -40 -99 8
-7 -51 -61 -60
-75 -51
-51 14
-10 -1
2
46 8 26 -16
-34 34 87 5
42 -43
66 -31
71 -30
2
31 100 6 1
-94 11 -63 81
-98 -53
-81 -51
70 -69
2
72 -74 -69 -61
-55 -58 90 83
32 -62
32 -20
25 -10
2
93 75 52 4
-86 91 -77 17
61 100
-49 -74
93 61
2
-61 39 97 -47
-34 2 12 -65
86 45
-18 7
67 -58...

output:

-1
93.722996110880
306.323358560852
424.794067755189
-1
-1
-1
294.015305724039
-1
436.497422672803

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 207ms
memory: 4332kb

input:

10
34
-59 -40 -99 8
-7 -51 -61 -60
-75 -51
-51 14
-10 -1
83
8 26 -16 -34
34 87 5 42
-43 66
-31 71
-30 9
43
-74 -69 -61 -55
-58 90 83 32
-62 32
-20 25
-10 25
92
-57 36 -6 -66
-13 43 3 -64
-43 -63
-56 -13
-21 -15
49
-12 72 88 67
-13 52 30 80
89 -46
62 41
-90 -74
42
-8 24 13 -99
71 -5 95 -11
66 98
77 9...

output:

-1
10662.626318126318
1623.922719836138
-1
-1
10356.723902856540
2554.141147235211
251.320512493509
18785.868146029344
-1

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 229ms
memory: 4444kb

input:

10
1
50 -37 48 -61
92 72 35 -3
-35 39
7 76
-82 55
1
96 -94 75 -85
15 30 -40 29
-34 -64
35 33
61 55
2
73 59 2 -19
38 84 -39 7
-1 -35
-43 -83
92 58
2
-21 10 92 -57
34 14 -51 62
-97 27
-82 -86
-88 54
2
-61 0 -94 10
15 32 91 12
28 -94
-44 9
-96 -49
1
-90 -1 -32 -19
79 15 -7 -67
-26 -5
1 83
-89 84
87
24 ...

output:

24.083189157585
22.847319317592
316.425346645935
394.109121944672
103.445637897400
60.728905802756
-1
-1
7094.119043263934
-1

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 198ms
memory: 4464kb

input:

10
58
87 38 79 -61
-3 11 -76 70
-88 33
4 -55
-68 -59
2
22 95 26 83
-14 26 -86 68
-63 -38
-67 0
39 43
2
6 92 -21 -16
-55 84 37 -16
-46 88
45 -18
-33 68
2
77 -51 -19 -26
31 10 51 62
27 20
-9 30
-86 -18
1
-94 16 -1 -72
-6 40 78 -89
-22 29
-38 27
-46 -47
1
1 80 -39 -32
-30 74 -76 -21
-31 -47
51 -42
-96 ...

output:

11422.111232167195
37.947331922021
-1
297.605443498603
130.680423399600
118.928549978548
23212.931962409520
180.623918681884
-1
9763.612292589255

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 195ms
memory: 4392kb

input:

10
2
-98 -5 21 69
-12 15 23 29
26 74
49 -74
80 41
2
65 -68 69 19
-28 49 -75 27
-49 11
74 50
49 -48
2
59 -88 7 28
-8 42 42 90
25 -65
78 29
82 60
14
43 -92 51 47
-45 -51 22 95
16 16
10 -55
76 68
90
-32 3 -77 -3
97 97 -46 38
-83 -16
-66 -21
-38 -84
17
-51 91 -71 -99
-37 -10 -75 -53
12 -54
30 47
86 -43
...

output:

420.396241657796
261.275716437636
-1
-1
8126.284575376376
-1
-1
851.630201437220
79.924964810752
-1

result:

ok 10 numbers

Test #15:

score: 0
Accepted
time: 190ms
memory: 4400kb

input:

10
2
39 71 -69 15
-24 -56 -17 -68
74 23
-65 -60
-17 73
1
-67 12 -45 -23
65 -88 -77 13
75 -68
-90 72
91 42
2
-89 -97 -48 6
14 17 -97 87
-92 -92
-23 -26
-18 -60
2
42 90 50 -34
4 43 5 -60
51 62
21 -5
33 85
2
-90 -39 46 18
35 6 -48 -61
-22 52
-33 63
-89 -42
1
-11 -39 -25 78
98 37 39 70
-54 -4
-80 -26
-5...

output:

-1
58.216253936290
-1
-1
-1
117.834629884427
6379.339307483182
-1
-1
-1

result:

ok 10 numbers

Test #16:

score: 0
Accepted
time: 174ms
memory: 4396kb

input:

10
1
-76 -65 -74 12
-22 9 95 61
-76 28
87 -78
-66 17
1
27 5 84 -27
12 95 -24 49
-36 -17
-41 89
-31 95
16
-9 84 92 -71
-43 1 -68 67
35 67
-39 -29
-62 -88
1
97 36 -23 30
94 -62 -58 -81
-62 -18
-22 11
50 -64
1
75 9 58 73
-16 58 -7 -16
17 9
14 6
73 -26
66
-77 -58 52 87
26 98 60 42
-65 -20
82 -62
-5 30
6...

output:

77.025969646607
65.368187981617
-1
120.149906367005
66.219332524573
-1
-1
-1
56.603886792340
163.559889419505

result:

ok 10 numbers

Test #17:

score: 0
Accepted
time: 180ms
memory: 4400kb

input:

10
2
-21 71 -58 45
16 40 58 -19
9 48
2 47
-58 16
10
-88 -31 -80 -73
93 -3 31 -89
0 30
-55 -95
-10 91
2
-46 -83 81 3
14 43 27 71
-24 -79
0 47
46 -71
11
-92 -30 -98 -94
89 3 19 22
-41 59
72 -46
-16 -20
72
-52 30 14 59
55 -66 -28 -14
88 -25
92 -3
-75 79
1
-46 88 51 16
81 57 -99 81
50 53
-99 37
4 -67
1
...

output:

135.665028655140
812.347216404414
-1
1349.893329119009
-1
181.532269942410
177.248413251008
-1
-1
10522.935902114010

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 204ms
memory: 4388kb

input:

10
1
20 82 -43 35
-14 -7 -74 -64
-57 87
51 -41
-73 60
84
-33 36 -62 -96
-33 -70 -64 -70
-7 46
87 -97
-60 -18
37
11 -1 98 -41
-73 -3 74 72
100 86
40 45
16 26
1
56 2 38 -96
54 49 -2 38
89 100
-81 -4
19 66
1
-19 -58 72 89
1 73 -65 26
-12 -66
89 92
45 -39
1
44 5 -28 95
-56 -31 60 92
90 -97
61 -86
67 -20...

output:

147.598124927925
-1
6990.107366843517
99.639349656649
172.887246493199
176.510151579491
128.413394939936
832.764672641677
141.351205473154
1467.479812467620

result:

ok 10 numbers

Test #19:

score: 0
Accepted
time: 225ms
memory: 4400kb

input:

10
2
-44 71 -77 10
60 92 24 98
-93 -55
-17 6
-10 27
2
91 -90 41 -82
45 -81 -99 -99
68 51
28 -75
-18 27
62
-54 -73 -13 61
58 90 42 100
29 37
-62 -36
-85 -19
12
25 -62 85 -12
66 92 -75 99
13 -32
-9 -68
-1 -96
1
-3 35 -48 91
85 -35 -6 -6
58 -82
-99 -24
-12 -6
2
83 62 45 81
1 -24 -53 23
-89 44
81 71
-31...

output:

208.062490612796
151.907866814066
-1
1796.357425458531
71.840100222647
-1
-1
152.322027297433
203.403539792207
386.290046467677

result:

ok 10 numbers

Test #20:

score: 0
Accepted
time: 199ms
memory: 4400kb

input:

10
1
-57 23 -54 -7
-96 -63 -77 5
77 -72
45 47
-53 82
1
17 -7 -60 -33
41 52 70 32
-7 84
-86 49
61 -15
6
11 -48 -4 -67
-87 93 77 33
-20 -65
11 -88
-31 -64
2
-1 24 1 74
-41 -23 -40 -55
-80 -14
-39 -1
-43 48
2
-83 -16 -36 71
3 18 -65 19
39 56
-15 -23
92 3
91
-15 61 0 60
-15 17 2 20
98 44
43 91
0 69
48
6...

output:

30.149626863363
81.271151093115
266.281805612024
150.119952038362
-1
2721.026644485496
12775.645776241606
-1
5139.097683445996
359.562233834423

result:

ok 10 numbers

Test #21:

score: 0
Accepted
time: 1053ms
memory: 4316kb

input:

96
1
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
100000
-2 0 2 0
-3 3 3 3
0 1
-3 -2
3 -2
2
-2 0 2 0
-3 3 -1 3
0 1
-3 -2
3 -2
2
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
1
2 0 -2 0
3 3 -3 3
0 1
-3 -2
3 -2
2
2 2 -2 2
3 3 -3 3
0 1
-3 -2
3 -2
2
0 0 4 0
0 2 4 2
1 1
3 1
2 -1
1
0 0 4 0
0 2 4...

output:

4.472135955000
13.416407864999
894422.718863960879
-1
-1
4.472135955000
12.000000000000
14.485281374239
4.472135955000
24.142135623731
6.472135955000
-1
8.261297173761
24.910407814435
41.559518455108
7.496976092671
34.702238339670
61.907500586668
7.496976092671
26.397277191929
45.108268355347
63.819...

result:

ok 96 numbers

Test #22:

score: 0
Accepted
time: 1954ms
memory: 4392kb

input:

100
1
-60 -41 -100 8
-8 -52 -62 -61
-76 -52
-52 14
-11 -2
1
46 8 26 -17
-35 34 87 5
42 -44
66 -32
71 -31
1
31 100 6 1
-95 11 -64 81
-99 -54
-82 -52
70 -70
1
72 -75 -70 -62
-56 -59 90 83
32 -63
32 -21
25 -11
1
93 75 52 4
-87 91 -78 17
61 100
-50 -75
93 61
1
-62 39 97 -48
-35 2 12 -66
86 45
-19 7
67 -...

output:

84.038465524562
32.015621187164
102.107786186951
142.593828758470
84.213958726168
193.956177007693
116.405688643376
99.362970970075
130.918250804478
146.819617217864
34.058772731853
196.621463731710
133.493513364303
223.235835693512
172.386194342819
148.003378339820
95.308350455347
178.291724699712
...

result:

ok 100 numbers

Test #23:

score: 0
Accepted
time: 2025ms
memory: 4452kb

input:

100
2
-83 38 19 6
-51 -93 96 82
-60 -60
66 90
-91 -56
2
30 94 -62 92
-33 -88 -7 -89
79 54
-57 -38
-18 30
2
-53 -6 -50 17
-8 -61 -34 41
52 70
32 -8
84 -87
2
61 -16 100 32
-32 67 34 81
-78 -21
-70 68
-39 31
2
20 -47 -77 6
58 36 -85 83
41 -92
-99 -65
-30 -74
2
-65 82 -18 76
8 -100 -35 -35
47 87
-52 18
...

output:

-1
276.065209687856
69.584481028459
185.539753152795
331.605186931688
142.144292885786
241.960740617151
413.358198176835
314.356485538314
-1
444.010135019461
147.732867026942
244.826469157238
-1
291.602469125349
411.962376922942
110.063617967065
233.634329669250
-1
138.812823615111
-1
114.0394668524...

result:

ok 100 numbers

Test #24:

score: 0
Accepted
time: 1901ms
memory: 4444kb

input:

98
43
14 -89 -10 27
6 -10 -2 14
65 -42
91 35
30 87
88
-71 -27 43 -66
96 86 -80 96
-97 13
-45 36
-8 -10
68
88 -70 -97 -19
8 -13 -89 76
58 60
-11 -98
28 19
22
-95 74 -94 -59
-24 -64 85 1
72 -30
0 -79
76 -71
59
45 -21 -3 79
2 53 63 9
-47 -94
-76 23
-81 -80
22
-56 64 -18 -7
92 -29 8 4
-34 -51
89 -84
27 ...

output:

10068.823168573376
21085.139909424362
-1
5719.161651850733
-1
3462.768401149577
16647.090586646064
3843.000000000000
-1
-1
7217.246912777753
11142.334809186089
-1
2913.383771493210
13443.716487638379
-1
23245.551079722761
10964.171195307012
-1
-1
-1
-1
-1
13078.743211792179
7941.694088794909
-1
1112...

result:

ok 98 numbers

Test #25:

score: 0
Accepted
time: 1973ms
memory: 4460kb

input:

100
2
-79 5 -18 49
0 3 24 -64
-78 -93
-36 -40
-95 -77
78
-68 29 -88 45
96 10 47 9
51 -6
-2 50
24 34
70
70 58 74 46
19 4 48 45
-3 11
-70 -31
15 -50
2
-46 99 6 31
41 87 -23 29
33 -47
23 -77
-38 -98
2
87 57 16 22
-60 84 -85 79
-79 -36
-88 80
-63 18
1
-86 -71 24 8
-35 43 61 -84
9 19
64 -30
2 27
1
40 -24...

output:

225.639092357685
3969.937027208366
1758.226379053619
-1
237.474209125960
194.268122227982
125.808304338479
418.325232325281
-1
32185.175624812116
-1
72.201108024739
-1
67.285874081256
510.987279685121
-1
1618.330312389903
9172.206386687993
107.296571965113
80.777472107018
83.006023877789
261.6199533...

result:

ok 100 numbers

Test #26:

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

input:

100
1
-9 32 -88 83
-18 38 77 85
-59 41
64 -52
7 -88
1
38 -50 85 83
96 -24 72 76
-51 -16
-26 55
-96 -43
1
-61 -62 93 2
-40 27 -69 -99
-56 93
-77 84
-93 20
1
1 -32 53 61
94 44 19 56
-3 -69
15 11
19 -77
1
-52 -23 35 75
-66 73 4 64
-31 -72
68 56
9 -34
1
-79 -18 6 -46
14 -48 85 -80
-75 -30
-9 -21
-80 -56...

output:

94.031909477581
145.271527868837
226.773200097994
124.187726846422
131.045793522722
99.219015696640
37.802116342872
304.644054594866
219.718001083207
-1
20788.317031448217
358.860697207147
-1
1770.136717883678
37.854986461495
386.208492915420
-1
255.704908048320
-1
170.578427709954
39.357337308309
1...

result:

ok 100 numbers