QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#443929#6763. Triangle Pendantpositive1AC ✓2ms3980kbC++141.9kb2024-06-15 16:51:592024-06-15 16:51:59

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 16:51:59]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3980kb
  • [2024-06-15 16:51:59]
  • 提交

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;
	}
	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);
	}
	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()
{
	ios::sync_with_stdio(false),cin.tie(0);
	int T;
	cin>>T;
	cout<<fixed<<setprecision(5);
	while(T--)
	{
		cin>>s[0]>>s[1]>>s[2]>>r[1][2]>>r[0][2]>>r[0][1];
		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();
		cout<<ans[0]<<' '<<ans[1]<<' '<<ans[2]<<'\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3920kb

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: 0
Accepted
time: 0ms
memory: 3916kb

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.93586 -2.00000 -13.35235
-22.14648 -16.07620 -12.24183
-28.02743 -18.31858 -8.24336
-27.26612 -13.15932 -26.88253
-26.53493 -22.06663 -29.61608
-26.96780 -12.55767 -14.18672
-15.77860 -20.86268 -5.15586
-10.93310 -21.91558 -17.77740
-18.04415 -3.00000 -15.74074
-4.13677 1.28738 -9.68713
-23.51828...

result:

ok 3000 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 3856kb

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.01585 -69.68404 -75.63806
-56.24137 -51.19422 -45.00000
-37.90514 -58.35085 -9.00000
-56.48752 -62.82624 -58.95570
-7.96090 -23.73091 -7.00000
-33.94871 -19.87509 -30.48288
-19.91039 -29.53161 -21.23514
-42.01981 -28.99441 -37.69641
-57.52828 -54.00000 -69.60284
-25.72174 -8.00000 -48.87860
-71....

result:

ok 3000 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 3932kb

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.00000 -213.85039 -223.04955
-177.40541 -126.00000 -222.59459
-233.00000 -255.05068 -243.87348
-159.00000 -219.73858 -199.69613
-201.80764 -276.32504 -207.00000
-723.00663 -657.19049 -652.00000
-314.47187 -277.89339 -308.25982
-691.00000 -684.63898 -737.68472
-66.47585 -8.00000 -92.12149
-205.27...

result:

ok 3000 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 3968kb

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.15854 -22.70585 -57.15335
-52.42611 -307.22190 -309.33479
-159.00000 -620.75600 -187.02865
-197.47110 -57.00000 -251.03899
-149.36824 -117.56092 -228.03548
-520.00000 -617.86453 -793.01551
-665.65535 -609.12245 -912.37345
-33.00000 155.85108 -551.85714
-355.47115 -566.08145 -662.73597
-748.8226...

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.24573 -25.99597 -122.73984
-33.00000 -55.05068 -43.87348
-49.83758 -55.92061 -80.00456
-83.88869 -63.59487 -138.12073
-4.00000 -56.98828 -60.30948
-73.54878 -0.14870 -8.00000
-67.02419 -3.00000 -43.43633
-27.10835 -17.99151 -5.00000
-56.50983 -79.68710 -16.00000
-40.65558 -32.20748 -86.75852
-84...

result:

ok 3000 numbers

Test #7:

score: 0
Accepted
time: 2ms
memory: 3980kb

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.14318 -81.04773 -64.00000
-77.40541 -26.00000 -122.59459
-121.60934 -164.29687 -79.00000
-80.24530 -102.14448 -9.00000
-124.42064 -64.00000 -98.67930
-139.88329 -63.00000 -132.87160
-119.70153 -110.66696 -33.00000
-123.00663 -57.19049 -52.00000
-130.79339 -84.26032 -47.00000
-91.00000 -84.63898...

result:

ok 3000 numbers