QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209080 | #6763. Triangle Pendant | ucup-team1004 | AC ✓ | 2ms | 3976kb | C++14 | 3.5kb | 2023-10-10 09:26:29 | 2023-10-10 09:26:29 |
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...);
}
const double eps=1e-10;
int T,x[3],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){}
};
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 d,ans[3];
void solve1(int a,int b,int c,int x,int y,int z,vector<int>cur){
if(abs(x-y)>=c||abs(x-z)>=b||abs(y-z)>=a)return;
vec A(0,0,0),B(c,0,0),C,D;
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);
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);
if(calc(O)<d){
// cout<<"Solve1\n";
d=calc(O);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}
}
void solve2(int c,int a,int b,int x,int y,vector<int>cur){
if(abs(x-y)>=c)return;
// debug("ok");
vec A(0,0,0),B(c,0,0),C,D;
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);
if(dis(A-D)-eps>::x[cur[0]]||dis(B-D)-eps>::x[cur[1]]||dis(C-D)-eps>::x[cur[2]])return;
vec O=(A+B+C)/3,n=O-D;
auto calc=[&](vec P){
return dot(P-D,n)/dis(n);
};
if(calc(O)>0)n=n*(-1);
if(calc(O)<d){
// cout<<"Solve2\n";
d=calc(O);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}
}
void solve3(int a,int b,int c,int x,vector<int>cur){
vec A(0,0,0),B(c,0,0),C,D;
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;
if(dis(A-D)-eps>::x[cur[0]]||dis(B-D)-eps>::x[cur[1]]||dis(C-D)-eps>::x[cur[2]])return;
// 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);
if(calc(O)<d){
// cout<<"Solve3\n";
d=calc(O);
ans[cur[0]]=calc(A),ans[cur[1]]=calc(B),ans[cur[2]]=calc(C);
}
}
void get(){
scanf("%d%d%d%d%d%d",&x[0],&x[1],&x[2],&a,&b,&c);
d=0;
fill(ans,ans+3,0);
solve1(a,b,c,x[0],x[1],x[2],{0,1,2});
solve2(a,b,c,x[1],x[2],{1,2,0});
solve2(b,c,a,x[2],x[0],{2,0,1});
solve2(c,a,b,x[0],x[1],{0,1,2});
solve3(a,b,c,x[0],{0,1,2});
solve3(b,c,a,x[1],{1,2,0});
solve3(c,a,b,x[2],{2,0,1});
// cout<<d<<endl;
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: 3856kb
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: 0
Accepted
time: 0ms
memory: 3976kb
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.352348999857673 -22.146476218003023 -16.076204705476879 -12.241826659011300 -28.027431433359666 -18.318582636182793 -8.243362186282258 -27.266119651334364 -13.159319584325656 -26.882525397692710 -26.534933366925667 -22.066632132649342 -29.616079568529663 -26...
result:
ok 3000 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 3976kb
input:
1000 33 73 79 36 44 48 96 66 45 9 13 14 81 64 9 50 30 26 59 64 65 39 44 13 47 63 7 20 11 27 36 20 52 13 22 20 20 30 29 12 2 12 46 36 41 34 28 39 97 54 70 16 14 5 79 8 97 41 24 18 95 83 59 47 15 50 85 78 67 22 13 17 96 32 70 32 15 18 27 34 76 38 13 29 47 86 95 42 17 34 41 50 50 25 33 22 82 42 81 18 4...
output:
-32.015847290392884 -69.684039776767534 -75.638061984052811 -56.241370959657523 -51.194224814505169 -45.000000000000007 -37.905135499813404 -58.350854686242002 -9.000000000000004 -56.487522082654571 -62.826241045256324 -58.955695838003926 -7.960896812205178 -23.730909200748957 -7.000000000000001 -33...
result:
ok 3000 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 3916kb
input:
1000 171 722 964 22 53 44 379 126 423 98 56 54 233 473 879 86 44 48 159 864 365 39 44 63 847 363 207 70 11 77 736 920 652 13 72 70 318 278 347 44 87 66 691 693 1000 64 50 19 879 8 297 91 74 68 536 888 163 33 44 27 495 83 959 97 65 100 968 643 337 32 61 46 204 797 870 52 62 59 885 978 167 72 63 17 22...
output:
-171.000000000000028 -213.850392599166867 -223.049554713779600 -177.405405405405389 -125.999999999999986 -222.594594594594554 -232.999999999999943 -255.050679634077540 -243.873475632231020 -159.000000000000000 -219.738578713327456 -199.696129350530072 -201.807639006052625 -276.325035973243189 -206.9...
result:
ok 3000 numbers
Test #5:
score: 0
Accepted
time: 2ms
memory: 3936kb
input:
1000 501 94 77 81 461 510 196 366 645 209 313 464 159 864 365 439 44 463 359 57 440 288 429 255 318 278 347 444 487 466 520 930 929 312 302 162 691 693 1000 564 250 519 33 292 661 856 572 306 410 665 850 503 313 592 947 186 395 292 817 634 466 581 266 563 125 647 672 653 583 469 216 496 554 457 945 ...
output:
-484.158538588081342 -22.705846490065895 -57.153345139618125 -52.426107263072424 -307.221896671166007 -309.334793607177630 -159.000000000000000 -620.756001522758538 -187.028645031214154 -197.471099288720751 -56.999999999999993 -251.038990245212375 -149.368244210288708 -117.560921904322612 -228.03547...
result:
ok 3000 numbers
Test #6:
score: 0
Accepted
time: 2ms
memory: 3916kb
input:
1000 79 26 423 98 56 54 33 473 79 86 44 48 59 64 365 39 44 63 95 83 959 97 65 100 4 97 870 52 62 59 405 53 8 11 66 75 96 3 407 45 46 67 57 847 5 38 42 72 77 173 16 68 47 53 54 57 945 80 52 83 795 18 100 67 56 72 67 42 748 48 3 50 29 35 566 52 38 18 23 56 116 35 37 15 800 12 62 54 99 74 7 696 95 38 3...
output:
-77.245731657992337 -25.995970870232856 -122.739840058138029 -32.999999999999993 -55.050679634077575 -43.873475632231091 -49.837583792988099 -55.920611549363898 -80.004560518101471 -83.888685265630201 -63.594872346937265 -138.120730907369420 -4.000000000000000 -56.988277917715756 -60.309480522244939...
result:
ok 3000 numbers
Test #7:
score: 0
Accepted
time: 2ms
memory: 3916kb
input:
1000 171 722 64 22 53 44 379 26 423 98 56 54 233 473 79 86 44 48 381 864 9 100 80 76 159 64 365 39 44 63 847 63 207 70 11 77 189 410 33 78 87 17 736 920 52 13 72 70 318 278 47 44 87 66 91 693 1000 64 50 19 879 8 297 91 74 68 536 888 63 33 44 27 95 83 959 97 65 100 968 643 37 32 61 46 4 797 870 52 62...
output:
-115.143181363696954 -81.047727121232313 -64.000000000000000 -77.405405405405403 -25.999999999999996 -122.594594594594597 -121.609344453051889 -164.296871189503918 -78.999999999999986 -80.245304603629464 -102.144476100646699 -9.000000000000002 -124.420643288021566 -64.000000000000000 -98.67930413572...
result:
ok 3000 numbers