QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#443869 | #6763. Triangle Pendant | positive1 | WA | 1ms | 3924kb | C++14 | 2.1kb | 2024-06-15 16:42:43 | 2024-06-15 16:42:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr double eps=1e-9;
int r[3][3],s[3];
double low,mid[3],ans[3];
template<typename T>T sqr(T x)
{
return x*x;
}
bool sing(int a)
{
int b=(a+1)%3,c=(a+2)%3;
double bm=r[b][c]/2.0,bm2=sqr(bm),am2=(sqr(r[a][b])+sqr(r[a][c]))/2.0-bm2,am=sqrt(am2);
mid[a]=am*2/3;
for(int i:{b,c})
{
int ab=r[a][i],ab2=sqr(ab);
double al=(am2+ab2-bm2)/am;
if(sqr(s[i])<al*s[a]+ab2+sqr(s[a])-eps) return false;
ans[i]=-s[a]-al/2;
}
//cerr<<a<<'\n';
ans[a]=-s[a];
return true;
}
double hei(double h,double x,double y)
{
return -(sqr(h)+sqr(y)-sqr(x))/2/h;
}
bool twin(int a,int b)
{
auto dis=[](double ad,double bd,double ab,double ac,double bc)
{
double cosdab=(sqr(ad)+sqr(ab)-sqr(bd))/2/ab/ad;
double coscab=(sqr(ac)+sqr(ab)-sqr(bc))/2/ab/ac;
double cosdac=cosdab*coscab-sqrt((1-sqr(cosdab))*(1-sqr(coscab)));
return sqrt(sqr(ad)+sqr(ac)-2*ad*ac*cosdac);
};
if(s[a]+s[b]<=r[a][b]||abs(s[a]-s[b])>=r[a][b]) return false;
int c=3-a-b;
double cd=dis(s[a],s[b],r[a][b],r[a][c],r[b][c]);
if(s[c]<cd-eps) return false;
double dg=dis(s[a],s[b],r[a][b],mid[a],mid[b]);
if(dg>low)
{
low=dg;
ans[a]=hei(dg,mid[a],s[a]);
ans[b]=hei(dg,mid[b],s[b]);
ans[c]=hei(dg,mid[c],cd);
}
//cerr<<dg<<' '<<mid[a]<<' '<<mid[b]<<' '<<mid[c]<<' '<<a<<' '<<b<<'\n';
return true;
}
bool pyr()
{
double dg=3*(sqr(s[0])+sqr(s[1])+sqr(s[2]))-sqr(r[0][1])-sqr(r[1][2])-sqr(r[0][2]);
if(dg<=0) return false;
dg=sqrt(dg)/3;
for(int i=0;i<3;i++) ans[i]=hei(dg,mid[i],s[i]);
return true;
}
int main()
{
//freopen("nbtea.in","r",stdin);
//freopen("nbtea.out","w",stdout);
ios::sync_with_stdio(false),cin.tie(0);
int T;
cin>>T;
cout<<fixed<<setprecision(5);
int id=0;
while(T--)
{
cin>>s[0]>>s[1]>>s[2]>>r[1][2]>>r[0][2]>>r[0][1];
id++;
if(id==21) cout<<s[0]<<' '<<s[1]<<' '<<s[2]<<' '<<r[1][2]<<' '<<r[0][2]<<' '<<r[0][1]<<'\n';
r[1][0]=r[0][1];
r[2][1]=r[1][2];
r[2][0]=r[0][2];
low=0;
sing(0)||sing(1)||sing(2)||(twin(0,1)|twin(1,2)|twin(0,2))||pyr();
if(T<2) cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<'\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3924kb
input:
2 1 1 1 1 1 1 2 3 3 1 1 1
output:
-0.81650 -0.81650 -0.81650 -2.00000 -2.86603 -2.86603
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3648kb
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:
24 3 21 4 26 27 -18.24579 -0.06516 -12.38107 -9.53812 -21.98116 -22.52699
result:
wrong answer 1st numbers differ - expected: '-2.93586', found: '24.00000', error = '9.17479'