QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209048 | #6763. Triangle Pendant | ucup-team1004 | WA | 2ms | 3968kb | C++14 | 2.5kb | 2023-10-10 07:51:27 | 2023-10-10 07:51:28 |
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));
}
void get(){
scanf("%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c);
int tx=x<min(y+c,z+b),ty=y<min(x+c,z+a),tz=z<min(x+b,y+a);
if(tx<ty)swap(tx,ty),swap(a,b);
if(tx<tz)swap(tx,tz),swap(c,a);
if(ty<tz)swap(ty,tz),swap(b,c);
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);
if(tz){
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 -abs(dot(P-D,n)/dis(n));
};
printf("%.15lf %.15lf %.15lf\n",calc(A),calc(B),calc(C));
}else if(ty){
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;
auto calc=[&](vec P){
return -abs(dot(P-D,n)/dis(n));
};
printf("%.15lf %.15lf %.15lf\n",calc(A),calc(B),calc(C));
}else{
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 -abs(dot(P-D,n)/dis(n));
};
printf("%.15lf %.15lf %.15lf\n",calc(A),calc(B),calc(C));
}
}
int main(){
for(scanf("%d",&T);T--;)get();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
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: 3968kb
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:
-21.000000000000000 -21.935856727586831 -32.352348999857668 -27.297258910924874 -18.823167017724742 -27.692792984154526 -28.027431433359677 -18.318582636182793 -8.243362186282255 -nan -nan -nan -26.534933366925671 -22.066632132649342 -29.616079568529663 -26.967804477491704 -12.557669395973875 -14.18...
result:
wrong answer 1st numbers differ - expected: '-2.93586', found: '-21.00000', error = '6.15294'