QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302088#6302. MapUSTC_fish_touching_team#AC ✓1ms3852kbC++171.7kb2024-01-10 16:10:022024-01-10 16:10:02

Judging History

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

  • [2024-01-10 16:10:02]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3852kb
  • [2024-01-10 16:10:02]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
using namespace std;
struct node{
	db x,y;
	node(){}
	node(db _x,db _y):x(_x),y(_y){}
	node operator + (node b) const{
		return node(x+b.x,y+b.y);
	}
	node operator - (node b) const{
		return node(x-b.x,y-b.y);
	}
	node operator * (db t) const{
		return node(x*t,y*t);
	}
	db operator * (node b) const{
		return x*b.x+y*b.y;
	}
	db getlen() const{
		return sqrt(x*x+y*y);
	}
	db getlen2() const{
		return x*x+y*y;
	}
	void prt() const{
		printf("%.5lf %.5lf\n",x,y);
	}
}pex,pey,mex,mey,s,t,sc[110],tc[110],ps,ms;
db getdis(node a,node b){
	return (b-a).getlen();
}
db getcos(node a,node b){
	return a*b/a.getlen()/b.getlen();
}
node trans(node a){
	node pv=a-ps;
	db xc=pv*pex/pex.getlen2();
	db yc=pv*pey/pey.getlen2();
	node mv=mex*xc+mey*yc; 
	return ms+mv;
}
int T,k,n;
int main(){
	scanf("%d",&T);
	while(T--){
		double x[5],y[5];
		for(int i=1;i<=4;i++){
			scanf("%lf%lf",&x[i],&y[i]);
		}
		ps=node(x[1],y[1]);
		pex=node(x[2],y[2])-node(x[1],y[1]);
		pey=node(x[4],y[4])-node(x[1],y[1]);
		
		for(int i=1;i<=4;i++){
			scanf("%lf%lf",&x[i],&y[i]);
		}
		ms=node(x[1],y[1]);
		mex=node(x[2],y[2])-node(x[1],y[1]);
		mey=node(x[4],y[4])-node(x[1],y[1]);
		
		scanf("%lf%lf%lf%lf",&s.x,&s.y,&t.x,&t.y);
		
		scanf("%d%d",&k,&n);
		
		sc[0]=s;
		for(int i=1;i<=n;i++){
			sc[i]=trans(sc[i-1]);
		}
		tc[0]=t;
		for(int i=1;i<=n;i++){
			tc[i]=trans(tc[i-1]);
		}
		
		db ans;
		for(int i=0;i<=n;i++){
			for(int j=0;i+j<=n;j++){
				if(i==0&&j==0)ans=(i+j)*k+getdis(sc[i],tc[j]);
				ans=min(ans,(i+j)*k+getdis(sc[i],tc[j]));
			}
		}
		
		printf("%.20lf\n",ans);
	}
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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.00000000000000000000
1.22726233524302896782

result:

ok 2 numbers

Test #2:

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

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.50065749974155515645
12.22973107892215693937
13.00000000000000000000
17.48853290037508045884
13.34166406412633421041
7.61577310586390865410
23.40939982143925135460
7.28010988928051805402
21.28003773408387644395
59.77602209257912591056
4.12310562561766058565
79.64923100695951063699
65.0691939399897...

result:

ok 100 numbers

Test #3:

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

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.00000000000000000000
25.48363797558436871782
40.22437072223753062872
18.38477631085023489277
9.21954445729288707412
18.02775637731994606838
43.11406302628034836744
52.88704435234900813612
45.54119014694280309641
55.00099997500124970884
37.00000000000000000000
12.04159457879229577770
24.3310501211...

result:

ok 100 numbers

Test #4:

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

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.24695047554425286762
8.00000000000000000000
45.92695228684296893107
135.11846653955188912732
131.97348218486925475190
40.34966595395349031605
15.32134772871249950299
77.77227503502049898998
66.73881303589942604049
8.00026665481581567008
116.80644603167310435765
12.58829001561599270076
170.7856302...

result:

ok 100 numbers

Test #5:

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

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.35008143300875360637
51.96763232093795892297
21.46869792814671740189
38.83793207646776579622
84.24818742830802875687
77.92945527847605546867
47.00000000000000000000
74.11549372591250062214
86.46710488042167241929
35.11409973215887703191
3.60555127546398912486
97.41663102366042892299
24.6060569657...

result:

ok 100 numbers

Test #6:

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

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.05586353287901602016
290.42570045093657427060
258.28240031306637547459
743.73718476354270023876
341.05278183882330722554
400.56668366243269474580
172.04079934095690873619
27.77089460983794566573
294.82588015208114029519
508.06591068887297524270
501.78182509931542654158
666.80506896693577800761
1...

result:

ok 100 numbers

Test #7:

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

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.43354954612925666879
96.88092305392839875822
530.33008588991060605622
44.01136216933077349722
64.31336536618194088533
7.39289366612623322084
34.56781020746208810124
148.85016074299255706137
350.33813591614818960807
329.22516277982123256152
68.86476510887298729813
32.82438317461281940268
244.6957...

result:

ok 100 numbers

Test #8:

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

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.47965700263054600327
977.20932282056662643299
94.48632505936063807894
307.00651458886017053374
1245.62955970063580934948
532.00000000000000000000
369.04877726392754766493
19.55402431723186396084
1509.00000000000000000000
275.09426721133075943726
4242.19335151470841083210
465.65625140881024890405
...

result:

ok 100 numbers

Test #9:

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

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.57488648929155772294
999.68927767812954243709
6231.52966774611468281364
550.94788609503552834212
182.54412465860630732095
5374.29679120905984746059
825.72578109665721513011
1653.20742916917060938431
2777.10964853748600944527
166.65302380610202703792
1747.00457927276193004218
651.11135760329045751...

result:

ok 100 numbers

Test #10:

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

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.64331697709323876211
41.43669871020131978412
39.20655561573370562201
11.18033988749894902526
49.72926703662542280426
26.92582403567251958521
50.93132631298737322822
10.29405582016538645007
117.88553770501282258465
8.60232526704262667749
48.46648326421053809554
21.09502310972898797559
24.038404810...

result:

ok 100 numbers

Test #11:

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

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.51754858215622334683
2119.67478013969866879052
1638.60149419540857707034
144.69968901141425021706
1706.29921174452874765848
2671.66801829868063578033
1442.32485938501395139610
2909.93127066602710328880
5311.38635386280293460004
7894.84420365595269686310
2950.72143720819576628855
1405.1972795871...

result:

ok 100 numbers

Test #12:

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

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.00394381264777621254
344430.70876447705086320639
597464.94716012221761047840
57512.00002125127502949908
180112.50498394944588653743
254594.18946546365623362362
13301.83436763094141497277
246235.74134150386089459062
17086.95373669630862423219
168329.00118814938468858600
580568.27843760116957128...

result:

ok 100 numbers

Test #13:

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

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.52377363913121399719
126504.99951860887813381851
57518.29369733306521084160
318943.66370254167122766376
169769.25000566878588870168
1497.13389306734075034910
23459.32499196518256212585
853.34781609536048563314
28.35141184590510832209
7526.10652403647782193730
36705.81656903984548989683
575.015321...

result:

ok 100 numbers

Test #14:

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

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.58456291067705024034
404181.38882437424035742879
311311.52891757799079641700
271785.62453706044470891356
319158.19183909409912303090
77725.02554349505226127803
103690.24156928993761539459
33781.00427755220152903348
16708.60835018883153679781
262422.76822714909212663770
176381.84309332974953576...

result:

ok 100 numbers