QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103281#6302. MapNerovixAC ✓4ms3748kbC++143.5kb2023-05-04 23:32:292023-05-04 23:32:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-04 23:32:30]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3748kb
  • [2023-05-04 23:32:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
// #define int ll
#define pii pair<int,int>
#define se second
#define fi first
#define mpr make_pair
#define ull unsigned long long
// const int mod=1e9+7;
const int mod=998244353;
int add(int x,int y){
	x+=y;return x>=mod?x-mod:x;
}
void adto(int&x,int y){
	x+=y;
	x>=mod?x-=mod:x;
}
int mul(int x,int y){
	return 1ll*x*y%mod;
}
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}
	return ans;
}

#define db double
void done(db x,db y,db ix,db iy,db jx,db jy,db&x_,db&y_){
    x_=ix*x+jx*y;
    y_=iy*x+jy*y;
}
void redone(db x_,db y_,db ix,db iy,db jx,db jy,db&x,db&y){
    y=(ix*y_-iy*x_)/(ix*jy-iy*jx);
    x=(jy*x_-jx*y_)/(ix*jy-iy*jx);
}
db Ax,Ay,Bx,By,Cx,Cy,Dx,Dy;
db A_x,A_y,B_x,B_y,C_x,C_y,D_x,D_y;
db sx,sy,tx,ty;
db ix,iy,jx,jy;
db i_x,i_y,j_x,j_y;
int n,k;
const int maxn=444;
const db eps=1e-10;
db px[maxn],py[maxn],tp[maxn];
int s,t;
int pc;
int valid(db x,db y){
    return x>=-eps&&x<=1+eps&&y>=-eps&&y<=1+eps;
}
db dis(db ax,db ay,db bx,db by){
    return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
void solve(){
    cin>>Ax>>Ay>>Bx>>By>>Cx>>Cy>>Dx>>Dy;
    cin>>A_x>>A_y>>B_x>>B_y>>C_x>>C_y>>D_x>>D_y;
    cin>>sx>>sy>>tx>>ty;
    cin>>k>>n;
    pc=0;
    ++pc;px[pc]=sx,py[pc]=sy;s=pc;tp[pc]=0;
    ix=Dx-Ax,iy=Dy-Ay;
    jx=Bx-Ax,jy=By-Ay;
    i_x=D_x-A_x,i_y=D_y-A_y;
    j_x=B_x-A_x,j_y=B_y-A_y;
    for(int i=1;i<=n;i++){
        db tmpx,tmpy;
        sx-=Ax,sy-=Ay;
        redone(sx,sy,ix,iy,jx,jy,tmpx,tmpy);
            // cerr<<tmpx<<" "<<tmpy<<"  emm1\n";
        if(valid(tmpx,tmpy)){
            done(tmpx,tmpy,i_x,i_y,j_x,j_y,sx,sy);
            sx+=A_x;
            sy+=A_y;
            ++pc;px[pc]=sx,py[pc]=sy;tp[pc]=i;
        }
        else break;
    }
    sx=px[s],sy=py[s];
    for(int i=1;i<=n;i++){
        db tmpx,tmpy;
        sx-=A_x,sy-=A_y;
        redone(sx,sy,i_x,i_y,j_x,j_y,tmpx,tmpy);
        if(valid(tmpx,tmpy)){
            done(tmpx,tmpy,ix,iy,jx,jy,sx,sy);
            sx+=Ax;
            sy+=Ay;
            ++pc;px[pc]=sx,py[pc]=sy;tp[pc]=i;
        }
        else break;
    }
    ++pc;px[pc]=tx,py[pc]=ty;t=pc;tp[pc]=0;
    for(int i=1;i<=n;i++){
        db tmpx,tmpy;
        tx-=Ax,ty-=Ay;
        redone(tx,ty,ix,iy,jx,jy,tmpx,tmpy);
        if(valid(tmpx,tmpy)){
            done(tmpx,tmpy,i_x,i_y,j_x,j_y,tx,ty);
            tx+=A_x;
            ty+=A_y;
            ++pc;px[pc]=tx,py[pc]=ty;tp[pc]=i;
        }
        else break;
    }
    tx=px[t],ty=py[t];
    for(int i=1;i<=n;i++){
        db tmpx,tmpy;
        tx-=A_x,ty-=A_y;
        redone(tx,ty,i_x,i_y,j_x,j_y,tmpx,tmpy);
        if(valid(tmpx,tmpy)){
            done(tmpx,tmpy,ix,iy,jx,jy,tx,ty);
            tx+=Ax;
            ty+=Ay;
            ++pc;px[pc]=tx,py[pc]=ty;tp[pc]=i;
        }
        else break;
    }
    // cerr<<pc<<" \n";
    // for(int i=1;i<=pc;i++){
    //     cerr<<px[i]<<" "<<py[i]<<" "<<tp[i]<<"   emm\n";
    // }
    db ans=1e18;
    for(int i=s;i<t;i++){
        for(int j=t;j<=pc;j++){
            if(tp[i]+tp[j]<=n)
            ans=min(ans,dis(px[i],py[i],px[j],py[j])+k*(tp[i]+tp[j]));
        }
    }
    cout<<ans<<"\n";
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(20);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	// cerr<<1.*clock()/CLOCKS_PER_SEC<<"s...\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3728kb

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: 2ms
memory: 3660kb

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: 3680kb

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.48363797558436516510
40.22437072223753062872
18.38477631085023489277
9.21954445729288707412
18.02775637731994606838
43.11406302628036968372
52.88704435234899392526
45.54119014694280309641
55.00099997500124970884
37.00000000000000000000
12.04159457879229577770
24.3310501211...

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 3ms
memory: 3728kb

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.32134772871250305570
77.77227503502049898998
66.73881303589936919707
8.00026665481584409179
116.80644603167310435765
12.58829001561598381898
170.7856302...

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 3ms
memory: 3676kb

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: 3ms
memory: 3632kb

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.42570045093634689692
258.28240031306637547459
743.73718476354270023876
341.05278183882330722554
400.56668366243269474580
172.04079934095690873619
27.77089460983754065637
294.82588015208114029519
508.06591068887263418219
501.78182509931542654158
666.80506896693577800761
1...

result:

ok 100 numbers

Test #7:

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

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.39289366612612930396
34.56781020746243626718
148.85016074299255706137
350.33813591614887172909
329.22516277982174415229
68.86476510887298729813
32.82438317461281940268
244.6957...

result:

ok 100 numbers

Test #8:

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

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.20932282056708118034
94.48632505936070913322
307.00651458886017053374
1245.62955970063580934948
532.00000000000000000000
369.04877726392754766493
19.55402431723194567326
1509.00000000000000000000
275.09426721132780357948
4242.19335151470841083210
465.65625140881121524217
...

result:

ok 100 numbers

Test #9:

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

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.57488648929233931995
999.68927767812954243709
6231.52966774611468281364
550.94788609503564202896
182.54412465860633574266
5374.29679120905984746059
825.72578109665585088806
1653.20742916917197362636
2777.10964853748600944527
166.65302380610125965177
1747.00457927276193004218
651.11135760329045751...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 4ms
memory: 3632kb

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: 4ms
memory: 3592kb

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: 3548kb

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.94716012233402580023
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: 3636kb

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.29369733314524637535
318943.66370254167122766376
169769.25000566878588870168
1497.13389306733120065473
23459.32499196511344052851
853.34781609534650215210
28.35141184596174923627
7526.10652403647782193730
36705.81656903984548989683
575.015321...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 4ms
memory: 3656kb

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