QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#43257#4497. MapBobWangWA 1023ms3844kbC++2.3kb2022-08-08 17:05:242022-08-08 17:05:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-08 17:05:25]
  • 评测
  • 测评结果:WA
  • 用时:1023ms
  • 内存:3844kb
  • [2022-08-08 17:05:24]
  • 提交

answer

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
inline long double read(){
    long double x;
    cin>>x;
    return x;
}
inline void cmax(int &a,int b){a<b?a=b:0;}
inline void cmin(int &a,int b){a>b?a=b:0;}
struct P{
    long double x,y;
    inline friend P operator -(P &x,P &y){
        return {x.x-y.x,x.y-y.y};
    }
    inline friend P operator +(P &x,P &y){
        return {x.x+y.x,x.y+y.y};
    }
    inline friend long double operator *(P &x,P &y){
        return {x.x*y.x+x.y*y.y};
    }
    inline friend P operator /(P &x,long double xx){
        return {x.x/xx,x.y/xx};
    }
};
inline long double sqr(long double x){
    return x*x;
}
inline long double dis(const P &x,const P &y){
    return sqrt(sqr(x.x-y.x)+sqr(x.y-y.y));
}
inline long double len(const P &x){
    return sqrt(sqr(x.x)+sqr(x.y));
}
signed main(){
    int T=read();
    while(T--){
        P A,B,C,D,a,b,c,d,AA,BB,CC,DD,aa,bb,cc,dd;
        B.x=read(),B.y=read();
        C.x=read(),C.y=read();
        D.x=read(),D.y=read();
        A.x=read(),A.y=read();
        b.x=read(),b.y=read();
        c.x=read(),c.y=read();
        d.x=read(),d.y=read();
        a.x=read(),a.y=read();
        AA=A-A,BB=B-A,CC=C-A,DD=D-A;
        aa=a-A,bb=b-A,cc=c-A,dd=d-A;
        // cout<<bb.x<<" "<<bb.y<<" -- "<<endl;
        P I=DD-AA,J=BB-AA,i=dd-aa,j=bb-aa;
        I=I/len(I),J=J/len(J),i=i/len(i),j=j/len(j);
        long double sigma=dis(AA,BB)/dis(aa,bb);
        // cout<<sigma<<endl;
        long double
            p=sigma*i.x-I.x,
            q=sigma*i.y-I.y,
            r=sigma*j.x-J.x,
            w=sigma*j.y-J.y,
            xx=sigma*i.x*aa.x+sigma*i.y*aa.y,
            yy=sigma*j.x*aa.x+sigma*j.y*aa.y;
        if(fabs(r*q-p*w)<1e-5){
            printf("%.6Lf %.6Lf\n",A.x,A.y);
            // cout<<fixed<<setprecision(10)<<A.x<<" "<<A.y<<endl;
            continue;
        }
        long double y=(r*xx-yy*p)/(r*q-p*w),
                    x=(xx-q*y)/p;
        printf("%.6Lf %.6Lf\n",x+A.x,y+A.y);
        // cout<<fixed<<setprecision(10)<<x+A.x<<" "<<y+A.y<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1023ms
memory: 3844kb

input:

100000
0 5
15 5
15 0
0 0
3 2
9 5
10 3
4 0
-605 604
604 605
605 -604
-604 -605
569 -338
568 -337
569 -336
570 -337
-964 963
963 964
964 -963
-963 -964
-364 838
-365 839
-364 840
-363 839
-664 663
663 664
664 -663
-663 -664
-307 -424
-308 -423
-307 -422
-306 -423
-866 865
865 866
866 -865
-865 -866
12...

output:

6.000000 2.000000
568.808264 -336.251240
-364.246369 838.376037
-306.450301 -422.912651
119.470554 796.609122
426.696565 50.239822
-138.701657 -400.855249
190.891912 -43.827206
-392.426023 -700.838405
96.510176 624.641791
576.278169 448.090845
-93.058682 165.791801
95.148725 -304.716714
-170.199256 ...

result:

wrong output format Expected double, but "-nan" found