QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769181 | #6302. Map | chenyitaoooo | WA | 0ms | 3928kb | C++14 | 2.1kb | 2024-11-21 16:30:49 | 2024-11-21 16:31:03 |
Judging History
answer
#include<bits/stdc++.h>
#define Ri register int
#define D long double
using namespace std;
const int N=123;
const D inf=1e8,eps=1e-9;
struct pt{
D x,y;
};
pt operator + (const pt x,const pt y){
pt z;
z.x=x.x+y.x;
z.y=x.y+y.y;
return z;
}
pt operator - (const pt x,const pt y){
pt z;
z.x=x.x-y.x;
z.y=x.y-y.y;
return z;
}
pt operator * (const D x,const pt y){
pt z;
z.x=y.x*x;
z.y=y.y*x;
return z;
}
struct nd{
D A,B,C,sq;
void gg(){
sq=sqrt(A*A+B*B);
}
};
D dis(const pt x,const pt y){
return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));
}
D Dis(const pt x,const nd y){
return fabs(x.x*y.A+x.y*y.B+y.C)/y.sq;
}
nd get(const pt x,const pt y){//
nd O;
if(fabs(x.y-y.y)<eps){
O.A=0,O.B=-1,O.C=y.y;
return O;
}
if(fabs(x.x-y.x)<eps){
O.A=-1,O.B=0,O.C=x.x;
return O;
}
double k=(x.y-y.y)/(x.x-y.x),b=x.y-x.x*k;
// if(fabs(b-(y.y-y.x*k))>eps) printf("!!!!");
O.A=k,O.B=-1,O.C=b;
return O;
}
struct jz{
pt a[5];
nd b[5];
D di[5];
void pr(){
for(Ri i=1; i<=4; ++i){
di[i]=dis(a[i],a[i%4+1]);
}
for(Ri i=1; i<=4; ++i){
b[i]=get(a[i],a[i%4+1]);
b[i].gg();
// if(fabs(a[i%4+1].x*b[i].A+a[i%4+1].y*b[i].B+b[i].C)>eps) printf("?");
// printf("%Lf %Lf %Lf\n",b[i].A,b[i].B,b[i].C);
}
}
}A[3];
pt aa[N],bb[N];
D ans;
int n,K;
pt trs(pt X){//
double aa=Dis(X,A[1].b[1])/A[1].di[2],bb=Dis(X,A[1].b[4])/A[1].di[1];
pt Y=A[2].a[1]+aa*(A[2].a[4]-A[2].a[1])+bb*(A[2].a[2]-A[2].a[1]);
// double cc=Dis(Y,A[2].b[1])/A[2].di[2],dd=Dis(Y,A[2].b[4])/A[2].di[1];
// if(fabs(aa-cc)>eps || fabs(bb-dd)>eps){
// printf("???");
// }
return Y;
}
void ext(pt x[N]){
for(Ri i=1; i<=n; ++i) x[i]=trs(x[i-1]);
}
void Sol(){
for(Ri i=1; i<=2; ++i){
for(Ri j=1; j<=4; ++j) scanf("%Lf %Lf",&A[i].a[j].x,&A[i].a[j].y);
A[i].pr();
}
scanf("%Lf %Lf %Lf %Lf",&aa[0].x,&aa[0].y,&bb[0].x,&bb[0].y);
scanf("%d %d",&K,&n);
ans=inf;
ext(aa),ext(bb);
for(Ri i=0; i<=n; ++i){
for(Ri j=0; j+i<=n; ++j){
ans=min(ans,dis(aa[i],bb[j])+(i+j)*K);
}
}
printf("%Lf\n",ans);
}
int main(){
int T;
scanf("%d",&T);
while(T--) Sol();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3928kb
input:
2 0 0 0 2 4 2 4 0 0 0 0 1 2 1 2 0 2 1 4 2 1 1 0 0 0 3 6 3 6 0 0 1 1 0 3 2 2 3 0 0 4 2 0 3
output:
1.000000 1.227262
result:
wrong answer 2nd numbers differ - expected: '1.2272623', found: '1.2272620', error = '0.0000003'