QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#786789#8677. Carl’s VacationWolamWA 1ms3940kbC++204.0kb2024-11-26 23:29:462024-11-26 23:29:50

Judging History

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

  • [2024-11-26 23:29:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3940kb
  • [2024-11-26 23:29:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double __float128
const double eps=1e-12;
struct ss{
    double x,y;
    double len()
    {
        return sqrtl(x*x+y*y);
    }
    double operator *(const ss ot)const{
        return x*ot.x+y*ot.y;
    }
    ss operator -(const ss ot)const{
        return (ss){x-ot.x,y-ot.y};
    }
    ss operator +(const ss ot)const{
        return (ss){x+ot.x,y+ot.y};
    }
    ss operator *(const double ot)const{
        return (ss){x*ot,y*ot};
    }
}a[4],b[4];
double mul(ss A,ss B)
{
    return A.x*B.y-A.y*B.x;
}
double dis(ss E,ss a,ss b)
{
    return fabsl(mul(E,a-b)/(a-b).len());
}
bool check(ss A,ss B,ss C,ss D)
{
    double l=min(A.x,B.x),r=max(A.x,B.x);
    double L=min(C.x,D.x),R=max(C.x,D.x);
    if(r+eps<L||R+eps<l)return 0;
    l=min(A.y,B.y),r=max(A.y,B.y);
    L=min(C.y,D.y),R=max(C.y,D.y);
    if(r+eps<L||R+eps<l)return 0;
    if(mul(B-A,C-A)*mul(B-A,D-A)>eps)
        return 0;
    if(mul(D-C,A-C)*mul(D-C,B-C)>eps)
        return 0;
    return 1;
}
void sol()
{
    int x1,y1,x2,y2,h1,h2;
    cin>>x1>>y1>>x2>>y2>>h1;
    a[0]=(ss){x1,y1};
    a[1]=(ss){x2,y2};
    ss p=a[1]-a[0];
    a[2]=(ss){a[1].x-p.y,a[1].y+p.x};
    a[3]=(ss){a[2].x-p.x,a[2].y-p.y};
    cin>>x1>>y1>>x2>>y2>>h2;
    b[0]=(ss){x1,y1};
    b[1]=(ss){x2,y2};
    p=b[1]-b[0];
    b[2]=(ss){b[1].x-p.y,b[1].y+p.x};
    b[3]=(ss){b[2].x-p.x,b[2].y-p.y};
    //cout<<(float)b[3].x<<" "<<(float)b[3].y<<endl;
    ss m1=(ss){(a[0].x+a[2].x)/2,(a[0].y+a[2].y)/2};
    ss m2=(ss){(b[0].x+b[2].x)/2,(b[0].y+b[2].y)/2};
    double d1=mul(m1-a[0],a[1]-a[0])/(a[1]-a[0]).len();
    double d2=mul(m2-b[0],b[1]-b[0])/(b[1]-b[0]).len();
    double len1=sqrtl(h1*h1+d1*d1);
    double llen1=sqrtl(h1*h1+(m1-a[0]).len()*(m1-a[0]).len());
    //cerr<<len1<<'\n';
    double len2=sqrtl(h2*h2+d2*d2);
    double llen2=sqrtl(h2*h2+(m2-b[0]).len()*(m2-b[0]).len());
    //cerr<<(float)len2<<'\n';
    double ans=1e18;
    for(int i=0;i<4;i++)
    {
        ss mm1=(ss){(a[i].x+a[(i+1)%4].x)/2,(a[i].y+a[(i+1)%4].y)/2};
        ss p1=m1-mm1;
        ss E=mm1+p1*(len1/p1.len());
        //cerr<<(float)len1<<" "<<(float)p1.len()<<endl;
        for(int j=0;j<4;j++)
        {
            ss mm2=(ss){(b[j].x+b[(j+1)%4].x)/2,(b[j].y+b[(j+1)%4].y)/2};
            ss p2=m2-mm2;
            ss F=mm2+p2*(len2/p2.len());
            //cout<<(float)E.x<<" "<<(float)E.y<<" "<<(float)F.x<<" "<<(float)F.y<<" "<<(float)b[j].x<<" "<<(float)b[j].y<<" "<<(float)b[(j+1)%4].x<<" "<<(float)b[(j+1)%4].y<<endl;
            if(check(b[j],b[(j+1)%4],E,F)&&check(a[i],a[(i+1)%4],E,F))
            {
                //cout<<(float)E.x<<" "<<(float)E.y<<" "<<(float)F.x<<" "<<(float)F.y<<" "<<i<<" "<<j<<" "<<(float)b[j].x<<" "<<(float)b[j].y<<endl;
                if((E-F).len()>len1+len2)
                    ans=min(ans,(E-F).len());
            }
            if(check(b[j],b[(j+1)%4],a[i],F))
            {
                ans=min(ans,(a[i]-F).len()+llen1);
            }
            if(check(a[i],a[(i+1)%4],b[j],E))
            {
                ans=min(ans,(b[j]-E).len()+llen2);
            }
            ans=min(ans,(a[i]-b[j]).len()+llen1+llen2);
        }
    }
    #undef double
    cout<<fixed<<setprecision(9)<<(long double)ans<<'\n';
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    sol();
}
/*
0 0 10 0 4
9 18 34 26 42
5 3.31662 21.5 67.5391 9 26 34 26 1
5 3.31662 21.5 67.5391 9 26 34 26 1
5 3.31662 21.5 67.5391 9 26 34 26 1
5 3.31662 21.5 67.5391 9 26 34 26 1
6.68338 5 -7.53914 38.5 34 26 34 51 0
6.68338 5 -7.53914 38.5 34 26 34 51 0
6.68338 5 -7.53914 38.5 34 26 34 51 0
6.68338 5 -7.53914 38.5 34 26 34 51 0
5 6.68338 21.5 9.46086 34 51 9 51 0
5 6.68338 21.5 9.46086 34 51 9 51 0
5 6.68338 21.5 9.46086 34 51 9 51 0
5 6.68338 21.5 9.46086 34 51 9 51 0
3.31662 5 50.5391 38.5 9 51 9 26 0
3.31662 5 50.5391 38.5 9 51 9 26 0
3.31662 5 50.5391 38.5 9 51 9 26 0
3.31662 5 50.5391 38.5 9 51 9 26 0
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

input:

1 0 0 0 10000
99999 10000 10000 10000 10000

output:

76118.700049220

result:

ok found '76118.7000492', expected '76118.7000492', error '0.0000000'

Test #2:

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

input:

10000 10000 10000 0 10000
0 0 0 10000 10000

output:

32360.679774998

result:

ok found '32360.6797750', expected '32360.6797750', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

0 0 100 100 20
0 0 -5 -5 2

output:

107.365555079

result:

ok found '107.3655551', expected '107.3655551', error '0.0000000'

Test #4:

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

input:

0 0 100 100 20
23 23 18 18 2

output:

88.056757051

result:

ok found '88.0567571', expected '88.0567571', error '0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

0 0 100 100 20
100 100 105 95 2

output:

107.365555079

result:

ok found '107.3655551', expected '107.3655551', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

0 0 100 100 20
44 156 49 151 2

output:

77.704520218

result:

ok found '77.7045202', expected '77.7045202', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

0 0 100 100 20
200 0 205 5 2

output:

224.528035157

result:

ok found '224.5280352', expected '224.5280352', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

0 0 100 100 20
-29 171 -24 176 2

output:

84.368195798

result:

ok found '84.3681958', expected '84.3681958', error '0.0000000'

Test #9:

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

input:

0 0 100 100 20
-100 100 -105 105 2

output:

107.365555079

result:

ok found '107.3655551', expected '107.3655551', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

0 0 100 100 20
-69 69 -74 74 2

output:

83.294612444

result:

ok found '83.2946124', expected '83.2946124', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

0 0 30 0 20
50 20 80 20 20

output:

72.801098893

result:

ok found '72.8010989', expected '72.8010989', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

0 0 30 0 20
50 20 80 20 140

output:

186.874948276

result:

ok found '186.8749483', expected '186.8749483', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

0 0 30 0 140
50 20 80 20 140

output:

302.264953761

result:

ok found '302.2649538', expected '302.2649538', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

0 0 30 0 500
50 20 80 20 140

output:

661.328793005

result:

ok found '661.3287930', expected '661.3287930', error '0.0000000'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

0 0 30 0 500
50 20 80 20 500

output:

1020.645871961

result:

ok found '1020.6458720', expected '1020.6458720', error '0.0000000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

0 0 30 0 500
50 20 80 20 2000

output:

2520.361473746

result:

ok found '2520.3614737', expected '2520.3614737', error '0.0000000'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

1137 -1096 229 -599 6253
5792 -405 3433 -9660 2912

output:

16631.267204638

result:

ok found '16631.2672046', expected '16631.2672046', error '0.0000000'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

-1458 4365 -759 -5184 408
8891 -5111 2941 -8564 6966

output:

14848.097967206

result:

ok found '14848.0979672', expected '14848.0979672', error '0.0000000'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

2289 1693 -2539 850 7414
-4989 3660 8091 2109 6915

output:

18844.470620502

result:

ok found '18844.4706205', expected '18844.4706205', error '0.0000000'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

5431 8457 6717 -6624 2204
-5504 -5607 4032 -674 7792

output:

20847.862166811

result:

ok found '20847.8621668', expected '20847.8621668', error '0.0000000'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

4274 -9998 -3313 -2647 4590
-792 1334 5701 -8048 3257

output:

16956.483471788

result:

ok found '16956.4834718', expected '16956.4834718', error '0.0000000'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

-1563 -4648 1926 -2970 5843
-1600 9113 -1007 5823 7516

output:

19666.620019250

result:

ok found '19666.6200193', expected '19666.6200193', error '0.0000000'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

-6957 -1204 -2026 2849 1571
9178 1160 -3263 -6525 9297

output:

22798.269165640

result:

ok found '22798.2691656', expected '22798.2691656', error '0.0000000'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

-5254 4877 5836 -1945 4282
8106 -8783 7076 -2291 6168

output:

17820.127104862

result:

ok found '17820.1271049', expected '17820.1271049', error '0.0000000'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

2278 -7979 -200 -9432 528
-8604 1343 -5214 2428 8005

output:

22690.415072392

result:

ok found '22690.4150724', expected '22690.4150724', error '0.0000000'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3924kb

input:

5003 277 737 -3626 2886
3492 4353 -446 5788 2426

output:

10058.391619179

result:

ok found '10058.3916192', expected '10058.3916192', error '0.0000000'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

-6582 -2629 -1742 6935 5531
-2010 1455 1794 -3461 9066

output:

20018.375726686

result:

ok found '20018.3757267', expected '20018.3757267', error '0.0000000'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

-8174 -1075 -6736 -2685 6615
-2151 4184 -1716 -308 5064

output:

16260.353232223

result:

ok found '16260.3532322', expected '16260.3532322', error '0.0000000'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

5291 1243 8982 5204 8450
-1177 -5306 -1390 2460 8858

output:

23316.850058254

result:

ok found '23316.8500583', expected '23316.8500583', error '0.0000000'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

-4229 2060 9017 -2659 5812
9887 -9973 5460 -2671 4205

output:

18310.304921594

result:

ok found '18310.3049216', expected '18310.3049216', error '0.0000000'

Test #31:

score: -100
Wrong Answer
time: 0ms
memory: 3936kb

input:

0 0 8 0 3
0 8 8 8 3

output:

12.806248475

result:

wrong answer 1st numbers differ - expected: '10.0000000', found: '12.8062485', error = '0.2806248'