QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209064 | #6763. Triangle Pendant | ucup-team1004 | WA | 2ms | 3972kb | C++14 | 3.8kb | 2023-10-10 08:39:24 | 2023-10-10 08:39:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
cerr<<x<<' ',debug(y...);
}
int T,x,y,z,a,b,c;
struct vec{
double x,y,z;
vec(double a=0,double b=0,double c=0):x(a),y(b),z(c){}
}A,B,C,D;
ostream& operator << (ostream &out,const vec &x){
return out<<'('<<x.x<<','<<x.y<<','<<x.z<<')';
}
vec operator + (const vec &a,const vec &b){
return vec(a.x+b.x,a.y+b.y,a.z+b.z);
}
vec operator - (const vec &a,const vec &b){
return vec(a.x-b.x,a.y-b.y,a.z-b.z);
}
vec operator / (const vec &a,const double &k){
return vec(a.x/k,a.y/k,a.z/k);
}
vec operator * (const vec &a,const double &k){
return vec(a.x*k,a.y*k,a.z*k);
}
vec cross(const vec &a,const vec &b){
return vec(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
double dot(const vec &a,const vec &b){
return a.x*b.x+a.y*b.y+a.z*b.z;
}
double dis(const vec &a){
return sqrt(dot(a,a));
}
int cur[3];
double ans[3];
void get(){
scanf("%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c);
// if(T==1000-227){
// printf("%d %d %d %d %d %d\n",x,y,z,a,b,c);
// }
auto calc=[&](int c,int a,int b,int x,int y){
vec A(0,0,0),B(c,0,0);
C.z=0,C.x=1.0*(b*b-a*a+c*c)/(c*2),C.y=sqrt(a*a-C.x*C.x);
D.z=0,D.x=1.0*(x*x-y*y+c*c)/(c*2),D.y=-sqrt(x*x-D.x*D.x);
return dis(C-D);
};
int tx=x<min(y+c,z+b),ty=y<min(x+c,z+a),tz=z<min(x+b,y+a);
iota(cur,cur+3,0);
if(tx<ty)swap(tx,ty),swap(x,y),swap(a,b),swap(cur[0],cur[1]);
if(tx<tz)swap(tx,tz),swap(x,z),swap(c,a),swap(cur[0],cur[2]);
if(ty<tz)swap(ty,tz),swap(y,z),swap(b,c),swap(cur[1],cur[2]);
if(tz){
// debug(x,y,z,a,b,c);
tx=x<calc(a,c,b,y,z),ty=y<calc(b,a,c,z,x),tz=z<calc(c,b,a,x,y);
if(tx<ty)swap(tx,ty),swap(x,y),swap(a,b),swap(cur[0],cur[1]);
if(tx<tz)swap(tx,tz),swap(x,z),swap(c,a),swap(cur[0],cur[2]);
if(ty<tz)swap(ty,tz),swap(y,z),swap(b,c),swap(cur[1],cur[2]);
// debug(tx,ty,tz);
if(!ty)goto S2;
if(!tz)goto S1;
A=vec(0,0,0),B=vec(c,0,0);
C.z=0,C.x=1.0*(b*b-a*a+c*c)/(c*2),C.y=sqrt(b*b-C.x*C.x);
D.x=1.0*(x*x+c*c-y*y)/(c*2);
D.y=(y*y-z*z+pow(D.x-C.x,2)-pow(D.x-c,2)+C.y*C.y)/(2*C.y);
D.z=sqrt(x*x-D.x*D.x-D.y*D.y);
// debug(A,B,C,D);
vec O=(A+B+C)/3,n1=cross(O-D,A-O)/dis(O-D),n2=cross(O-D,B-O)/dis(O-D);
vec n=cross(n1,n2)/dis(n1);
auto calc=[&](vec P){
return dot(P-D,n)/dis(n);
};
if(calc(O)>0)n=n*(-1);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}else if(ty){
S1:;
A=vec(0,0,0),B=vec(c,0,0);
C.z=0,C.x=1.0*(b*b-a*a+c*c)/(c*2),C.y=sqrt(b*b-C.x*C.x);
D.z=0,D.x=1.0*(x*x-y*y+c*c)/(c*2),D.y=-sqrt(x*x-D.x*D.x);
vec O=(A+B+C)/3,n=O-D;
if(cross(O-D,A-D).z<0&&cross(O-D,B-D).z<0)goto S2;
if(cross(O-D,A-D).z>0&&cross(O-D,B-D).z>0){
swap(a,b),swap(cur[0],cur[1]),swap(x,y);
goto S1;
}
auto calc=[&](vec P){
return dot(P-D,n)/dis(n);
};
if(calc(O)>0)n=n*(-1);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}else{
S2:;
A=vec(0,0,0),B=vec(c,0,0);
C.z=0,C.x=1.0*(b*b-a*a+c*c)/(c*2),C.y=sqrt(b*b-C.x*C.x);
vec O=(A+B+C)/3,m=A-O;
D=A+m/dis(m)*x;
// debug(A,B,C,D);
vec n=O-D;
auto calc=[&](vec P){
return dot(P-D,n)/dis(n);
};
if(calc(O)>0)n=n*(-1);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}
// debug(ary(cur,0,2));
// if(T<10)
for(int i=0;i<3;i++)printf("%.15lf%c",ans[i],"\n "[i<2]);
}
int main(){
for(scanf("%d",&T);T--;)get();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3972kb
input:
2 1 1 1 1 1 1 2 3 3 1 1 1
output:
-0.816496580927726 -0.816496580927726 -0.816496580927726 -2.000000000000000 -2.866025403784439 -2.866025403784439
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3932kb
input:
1000 21 2 14 12 13 4 29 19 13 15 10 17 29 24 15 29 24 23 29 17 30 18 9 25 27 24 30 16 4 15 28 13 17 12 21 16 16 22 10 22 15 8 15 23 24 23 27 13 26 3 27 15 16 17 5 8 20 17 6 12 24 14 13 15 19 13 27 22 18 18 23 30 22 18 14 11 29 28 7 13 22 22 17 11 19 9 16 22 20 17 21 14 20 6 29 25 20 10 19 9 27 27 17...
output:
-2.935856727586833 -2.000000000000000 -13.352348999857675 -22.146476218003027 -16.076204705476879 -12.241826659011300 -28.027431433359677 -18.318582636182793 -8.243362186282258 nan -nan -nan -26.534933366925671 -22.066632132649342 -29.616079568529663 -28.260464288238392 -12.716299904082387 -14.29926...
result:
wrong output format Expected double, but "nan" found