QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#588815#8078. Spanning TreeSwd146296#WA 0ms3908kbC++141.8kb2024-09-25 14:42:292024-09-25 14:42:30

Judging History

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

  • [2024-09-25 14:42:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2024-09-25 14:42:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const long double eps=1e-9;
const long double inf=100000000000.0;

int T;
int read()
{
    int r=0, f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
    return r*f;
}
int main()
{
    // freopen("testdata.in","r",stdin);
    T=read();
    while(T--)
    {
        ld x11,y11,x12,y12,x21,y21,x22,y22;
        cin >> x11 >> y11 >> x12 >> y12;
        cin >> x21 >> y21 >> x22 >> y22;
        ld X1=(x11+x12)/2, Y1=(y11+y12)/2, X2=(x21+x22)/2, Y2=(y21+y22)/2;
        // cout << X1 << " " << Y1 << " " << X2 << " " << Y2 << '\n';
        ld dis=(Y2-Y1)*(Y2-Y1)+(X2-X1)*(X2-X1);
        ld r=(y22-y21)*(y22-y21)+(x22-x21)*(x22-x21);
        ld R=(y12-y11)*(y12-y11)+(x12-x11)*(x12-x11);
        if(r/4>dis)
        {
            cout << fixed << setprecision(10) << sqrt(R/8) << '\n';
        }
        else
        {
            r/=8;
            ld ans=inf;
            ld NX=X2-sqrt(r), NY=Y2-sqrt(r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX+=2*sqrt(r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NY+=2*sqrt(r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX-=2*sqrt(r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX=X2, NY=Y2-sqrt(2*r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX+=sqrt(2*r), NY+=sqrt(2*r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX-=sqrt(2*r), NY+=sqrt(2*r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            NX-=sqrt(2*r), NY-=sqrt(2*r);
            ans=min(ans,abs(NX-X1)+abs(NY-Y1));
            cout << fixed << setprecision(10) << ans << '\n';
        }        
    }
    return (0-0);
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3908kb

input:

3
1 2
1 3
1 2
1 3

output:

0.3535533906
0.3535533906
0.3535533906

result:

wrong answer 1st lines differ - expected: '499122177', found: '0.3535533906'