QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769184#6302. MapchenyitaooooAC ✓2ms3940kbC++142.1kb2024-11-21 16:31:442024-11-21 16:31:46

Judging History

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

  • [2024-11-21 16:31:46]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3940kb
  • [2024-11-21 16:31:44]
  • 提交

answer

#include<bits/stdc++.h>
#define Ri register int
#define D long double 
using namespace std;
const int N=123;
const D inf=1e8,eps=1e-9;
struct pt{
	D x,y;
};
pt operator + (const pt x,const pt y){
	pt z;
	z.x=x.x+y.x;
	z.y=x.y+y.y;
	return z;
}
pt operator - (const pt x,const pt y){
	pt z;
	z.x=x.x-y.x;
	z.y=x.y-y.y;
	return z;
}
pt operator * (const D x,const pt y){
	pt z;
	z.x=y.x*x;
	z.y=y.y*x;
	return z;
}
struct nd{
	D A,B,C,sq;
	void gg(){
		sq=sqrt(A*A+B*B);
	}
};
D dis(const pt x,const pt y){
	return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));
}
D Dis(const pt x,const nd y){
	return fabs(x.x*y.A+x.y*y.B+y.C)/y.sq;
}
nd get(const pt x,const pt y){//
	nd O;
	if(fabs(x.y-y.y)<eps){
		O.A=0,O.B=-1,O.C=y.y;
		return O;
	}
	if(fabs(x.x-y.x)<eps){
		O.A=-1,O.B=0,O.C=x.x;
		return O;
	}
	double k=(x.y-y.y)/(x.x-y.x),b=x.y-x.x*k;
//	if(fabs(b-(y.y-y.x*k))>eps) printf("!!!!");
	O.A=k,O.B=-1,O.C=b;
	return O;
}
struct jz{
	pt a[5];
	nd b[5];
	D di[5];
	void pr(){
		for(Ri i=1; i<=4; ++i){
			di[i]=dis(a[i],a[i%4+1]);
		}
		for(Ri i=1; i<=4; ++i){
			b[i]=get(a[i],a[i%4+1]);
			b[i].gg();
//			if(fabs(a[i%4+1].x*b[i].A+a[i%4+1].y*b[i].B+b[i].C)>eps) printf("?");
//			printf("%Lf %Lf %Lf\n",b[i].A,b[i].B,b[i].C);
		}
	}
}A[3];
pt aa[N],bb[N];
D ans;
int n,K;
pt trs(pt X){//
	double aa=Dis(X,A[1].b[1])/A[1].di[2],bb=Dis(X,A[1].b[4])/A[1].di[1];
	pt Y=A[2].a[1]+aa*(A[2].a[4]-A[2].a[1])+bb*(A[2].a[2]-A[2].a[1]);
//	double cc=Dis(Y,A[2].b[1])/A[2].di[2],dd=Dis(Y,A[2].b[4])/A[2].di[1];
//	if(fabs(aa-cc)>eps || fabs(bb-dd)>eps){
//		printf("???");
//	}
	return Y;
}
void ext(pt x[N]){
	for(Ri i=1; i<=n; ++i) x[i]=trs(x[i-1]);
}
void Sol(){
	for(Ri i=1; i<=2; ++i){
		for(Ri j=1; j<=4; ++j) scanf("%Lf %Lf",&A[i].a[j].x,&A[i].a[j].y);
		A[i].pr();
	}
	scanf("%Lf %Lf %Lf %Lf",&aa[0].x,&aa[0].y,&bb[0].x,&bb[0].y);
	scanf("%d %d",&K,&n);
	ans=inf;
	ext(aa),ext(bb);
	for(Ri i=0; i<=n; ++i){
		for(Ri j=0; j+i<=n; ++j){
			ans=min(ans,dis(aa[i],bb[j])+(i+j)*K);
		}
	}
	printf("%.11Lf\n",ans);
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--) Sol();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
0 0 0 2 4 2 4 0
0 0 0 1 2 1 2 0
2 1 4 2
1 1
0 0 0 3 6 3 6 0
0 1 1 0 3 2 2 3
0 0 4 2
0 3

output:

1.00000000000
1.22726233524

result:

ok 2 numbers

Test #2:

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

input:

100
-133 -128 -109 -134 -85 -38 -109 -32
-95 -37 -100 -35 -108 -55 -103 -57
-119 -130 -112 -44
2 73
5 -100 5 -8 1 -8 1 -100
1 -60 1 -14 3 -14 3 -60
3 -84 1 -20
2 53
-58 -78 -66 -78 -66 -34 -58 -34
-58 -34 -66 -34 -66 -78 -58 -78
-63 -50 -63 -37
4 54
52 -148 116 -148 116 -52 52 -52
53 -103 53 -71 101...

output:

9.50065749974
12.22973107892
13.00000000000
17.48853290038
13.34166406413
7.61577310586
23.40939982144
7.28010988928
21.28003773408
59.77602209258
4.12310562562
79.64923100696
65.06919393999
14.14213562373
41.82461550348
16.05624518490
15.67261752993
21.56220237420
66.27216610312
21.02379604163
20.8...

result:

ok 100 numbers

Test #3:

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

input:

100
-173 -113 -120 -113 -120 -115 -173 -115
-173 -115 -120 -115 -120 -113 -173 -113
-162 -114 -152 -114
99 57
6 23 -75 4 -56 -77 25 -58
0 -58 -51 -69 -62 -18 -11 -7
-22 -56 -42 -25
19 27
-98 -115 -150 -147 -158 -134 -106 -102
-150 -147 -98 -115 -106 -102 -158 -134
-103 -111 -136 -134
25 50
136 -92 1...

output:

10.00000000000
25.48363797558
40.22437072224
18.38477631085
9.21954445729
18.02775637732
43.11406302628
52.88704435235
45.54119014694
55.00099997500
37.00000000000
12.04159457879
24.33105012119
18.11077027627
7.56326275328
2.23606797750
8.23606797750
14.86476510887
6.32455532034
62.48732656691
37.65...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

100
-12 -206 72 -188 135 -482 51 -500
19 -301 23 -301 23 -315 19 -315
88 -368 28 -248
14 87
-221 -566 -467 -566 -467 -565 -221 -565
-221 -566 -467 -566 -467 -565 -221 -565
-297 -566 -289 -566
274 18
-264 759 -339 609 -129 504 -54 654
-208 580 -208 655 -103 655 -103 580
-196 664 -211 596
8 64
-111 -3...

output:

34.24695047554
8.00000000000
45.92695228684
135.11846653955
131.97348218487
40.34966595395
15.32134772871
77.77227503502
66.73881303590
8.00026665482
116.80644603167
12.58829001562
170.78563026629
131.96275042909
8.73808997516
17.46424919657
15.49965984287
26.06983614564
258.07363290348
17.745735329...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

100
-235 -704 133 -704 133 -720 -235 -720
-224 -712 -40 -712 -40 -704 -224 -704
15 -711 76 -718
4 74
-467 574 -475 596 -123 724 -115 702
-274 662 -270 652 -430 588 -434 598
-458 588 -241 657
15 31
380 -3 532 -343 787 -229 635 111
503 -71 639 -163 708 -61 572 31
533 -189 613 -137
3 58
-460 -7 -488 -7...

output:

31.35008143301
51.96763232094
21.46869792815
38.83793207647
84.24818742831
77.92945527848
47.00000000000
74.11549372591
86.46710488042
35.11409973216
3.60555127546
97.41663102366
24.60605696576
56.77335943272
6.99853461941
13.45362404707
150.78616572347
65.85590330411
26.17250465660
128.03515142335
...

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

100
-1201 2822 -1197 2814 -3437 1694 -3441 1702
-3119 1860 -3117 1856 -1997 2416 -1999 2420
-1419 2709 -2491 2174
48 76
-2515 285 -2547 306 -1308 2194 -1276 2173
-2255 683 -2260 686 -2083 981 -2078 978
-1572 1753 -1392 2015
121 28
-1216 1209 -1498 -1141 -1598 -1129 -1316 1221
-1494 -823 -1494 -447 -...

output:

264.05586353288
290.42570045094
258.28240031307
743.73718476354
341.05278183882
400.56668366243
172.04079934096
27.77089460984
294.82588015208
508.06591068887
501.78182509932
666.80506896694
180.06943105369
193.61043360315
1507.00298606207
25.01999200639
81.74800749849
346.02898428973
105.4786686997...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

100
1411 -2755 603 -3563 623 -3583 1431 -2775
716 -3477 1120 -3073 1110 -3063 706 -3467
1210 -2959 1339 -2830
2319 39
4528 -3417 4286 -4055 1908 -3153 2150 -2515
2094 -2892 2094 -3090 2832 -3090 2832 -2892
2257 -2993 4389 -3736
17 22
-180 -1673 -2172 -3665 -2164 -3673 -172 -1681
-284 -1792 -2027 -35...

output:

182.43354954613
96.88092305393
530.33008588991
44.01136216933
64.31336536618
7.39289366613
34.56781020746
148.85016074299
350.33813591615
329.22516277982
68.86476510887
32.82438317461
244.69572942738
685.96883771198
141.36274799594
1601.78982672272
6.88559114617
70.67146070563
5.17965442927
277.0649...

result:

ok 100 numbers

Test #8:

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

input:

100
11928 -18111 8928 -17411 11056 -8291 14056 -8991
11043 -10811 10793 -10111 12921 -9351 13171 -10051
10491 -14092 11923 -12413
10 92
11869 -4371 3539 5429 1299 3525 9629 -6275
8302 -3064 3647 2571 4935 3635 9590 -2000
2384 2680 3466 2644
181 91
4001 -10187 4001 -10897 9 -10897 9 -10187
838 -10629...

output:

87.47965700263
977.20932282057
94.48632505936
307.00651458886
1245.62955970064
532.00000000000
369.04877726393
19.55402431723
1509.00000000000
275.09426721133
4242.19335151471
465.65625140881
3478.30424206018
1754.35600720036
1804.46692758593
21.35314266063
415.41553462457
1526.43440736902
3853.6029...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

100
10303 -4099 19487 -8131 19703 -7639 10519 -3607
18394 -7495 18842 -7271 18854 -7295 18406 -7519
15852 -6248 15950 -6389
38 10
13132 -3411 17416 3393 15634 4515 11350 -2289
13143 -873 15411 3411 16533 2817 14265 -1467
16515 2577 16017 1561
198 94
-5480 10872 -6297 11294 -11361 1490 -10544 1068
-1...

output:

84.57488648929
999.68927767813
6231.52966774611
550.94788609503
182.54412465861
5374.29679120906
825.72578109666
1653.20742916917
2777.10964853749
166.65302380610
1747.00457927276
651.11135760329
242.21000673227
34.26689584622
286.79086456859
2405.24662892058
2133.34221352318
1310.97813157377
48.466...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

100
0 -30 84 12 126 -72 42 -114
0 -30 84 12 126 -72 42 -114
91 -41 100 -55
96 93
168 110 148 150 48 100 68 60
48 100 68 60 168 110 148 150
61 96 102 90
8 2
-123 129 -60 174 -15 111 -78 66
-15 111 -78 66 -123 129 -60 174
-44 115 -104 132
27 3
27 42 15 54 -75 -36 -63 -48
-63 -48 -75 -36 15 54 27 42
-4...

output:

16.64331697709
41.43669871020
39.20655561573
11.18033988750
49.72926703663
26.92582403567
50.93132631299
10.29405582017
117.88553770501
8.60232526704
48.46648326421
21.09502310973
24.03840481041
16.00000000000
48.54894437575
26.06175685955
39.53983207834
10.77032961427
20.97321374946
7.28010988928
5...

result:

ok 100 numbers

Test #11:

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

input:

100
9725 6731 9725 11971 14965 11971 14965 6731
9725 6731 9725 11971 14965 11971 14965 6731
10293 11185 10445 9833
488 10
3833 -4831 6913 -4271 8443 -12686 5363 -13246
6913 -4271 3833 -4831 5363 -13246 8443 -12686
5209 -4960 7133 -6409
1 88
-5891 -6066 -8365 -6066 -8365 -8540 -5891 -8540
-8365 -6066...

output:

1360.51754858216
2119.67478013970
1638.60149419541
144.69968901141
1706.29921174453
2671.66801829868
1442.32485938501
2909.93127066603
5311.38635386280
7894.84420365595
2950.72143720820
1405.19727958717
8052.78597753597
436.08485412818
1910.19014712379
1597.00782715677
8923.07934515882
3776.23357328...

result:

ok 100 numbers

Test #12:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

100
1432065 -1359744 1432065 -1359796 610089 -1359796 610089 -1359744
610089 -1359744 610089 -1359796 1432065 -1359796 1432065 -1359744
1413145 -1359747 670086 -1359765
306 12
-630899 -570942 344981 -570942 344981 -567164 -630899 -567164
-630899 -567164 344981 -567164 344981 -570942 -630899 -570942
...

output:

41383.00394381265
344430.70876447704
597464.94716012226
57512.00002125127
180112.50498394933
254594.18946546365
13301.83436763092
246235.74134150387
17086.95373669631
168329.00118814939
580568.27843760117
120047.47596504529
24722.57593779418
252882.79871909042
366.88234114588
108187.76857333680
2882...

result:

ok 100 numbers

Test #13:

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

input:

100
-240497 1168822 -365542 931192 504344 473443 629389 711073
226221 683190 167481 688085 185400 903113 244140 898218
-192129 1110656 34450 941656
2 25
1729381 25950 1512625 519672 1528369 526584 1745125 32862
1536820 492965 1580974 388601 1584302 390009 1540148 494373
1660204 207517 1601591 344571...

output:

33.52377363916
126504.99951860884
57518.29369733296
318943.66370254168
169769.25000566878
1497.13389306734
23459.32499196513
853.34781609536
28.35141184590
7526.10652403645
36705.81656903984
575.01532167523
4025.08488222493
31458.02366646703
316549.01455698768
52928.37088934440
136396.39329148618
10...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

100
-889209 606569 -191736 1436894 638589 739421 -58884 -90904
-58884 -90904 638589 739421 -191736 1436894 -889209 606569
-486300 891465 -464854 988546
79 18
-1226546 957048 -712144 1926170 -590407 1861553 -1104809 892431
-712144 1926170 -1226546 957048 -1104809 892431 -590407 1861553
-807239 146415...

output:

99421.58456291068
404181.38882437425
311311.52891757799
271785.62453706046
319158.19183909411
77725.02554349504
103690.24156928994
33781.00427755220
16708.60835018883
262422.76822714907
176381.84309332976
159818.48394037531
451836.63422081360
291664.04018088769
406095.26661240463
591425.31798697965
...

result:

ok 100 numbers