QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569371#8081. Minimum Manhattan Distanceliubw_#AC ✓96ms3996kbC++20911b2024-09-16 22:26:042024-09-16 22:26:06

Judging History

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

  • [2024-09-16 22:26:06]
  • 评测
  • 测评结果:AC
  • 用时:96ms
  • 内存:3996kb
  • [2024-09-16 22:26:04]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define max(A,B) (A>B? A:B)
#define min(A,B) (A<B? A:B)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define pir(X) pair<X,X>
#define mpr(A,B) make_pair(A,B)
#define fr first
#define sc second
using namespace std;

void slv(){
    int x1,x2,y1,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    cin>>x3>>y3>>x4>>y4;
    ldb ans=((ldb)(abs(x1+x2-x3-x4)+abs(y1+y2-y3-y4)))/2.0;
    ldb r=0.5*(ldb)sqrt((ll)(x4-x3)*(x4-x3)+(ll)(y3-y4)*(y3-y4));
    // cout<<ans<<' '<<r<<'\n';
    cout<<fixed<<setprecision(12)<<ans-sqrt(2)*r<<'\n';
}

void fst_IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main(){
    fst_IO();
    int T;
    cin>>T;
    while(T--){
        slv();
    }
    return 0;
}

/*

1
2 1 0 0
4 5 5 2


*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3924kb

input:

1
0 0 2 1
4 5 5 2

output:

4.263932022500

result:

ok Your answer is acceptable!^ ^

Test #2:

score: 0
Accepted
time: 96ms
memory: 3888kb

input:

100000
64184 -33682 59295 3067
16568 83379 -30901 17899
4747 16156 33365 80028
-41011 -93961 -89583 -95743
96914 -33206 12828 -88885
-93518 29681 -82022 42270
40225 76998 25677 84480
66361 -32945 94822 -81258
-17979 41800 -91442 80586
40229 -78184 30070 -89624
-21082 -94587 48262 -87979
-95197 91518...

output:

77664.492686403206
192928.302701440659
227607.106035306657
145831.444580046043
224138.523189468861
203168.416322626160
106258.702187296649
114459.030348488982
130191.378343408272
92639.995133674127
110927.182439468237
121482.255326366725
130471.051428038907
193239.869930903343
101942.177602244952
22...

result:

ok Your answer is acceptable!^ ^

Test #3:

score: 0
Accepted
time: 94ms
memory: 3832kb

input:

100000
-18320 -12065 -63211 -70160
25465 23684 51590 90971
320 47201 7943 81396
-92700 -32637 -74486 -4692
99421 19908 91756 -28366
25529 -55621 18271 -78859
27654 -68417 31755 -96497
-26728 -28568 -50384 -393
-10805 -86093 7305 -27809
-64498 85696 -76254 19562
84518 11339 26149 17948
2447 55045 -13...

output:

126693.525110459847
147100.715342060712
119484.924663965710
110223.186736658537
130709.108038525292
92808.270238245115
118867.001846637716
297697.871129691147
213765.602167080845
90968.357807112009
165745.367435086441
184370.169144306107
184241.466886319904
132742.831368450056
129347.612579535539
11...

result:

ok Your answer is acceptable!^ ^

Test #4:

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

input:

100000
37495 80384 -22610 56295
-62653 -47270 -62203 -6381
-86440 63964 25226 91598
62192 -71344 39815 -45590
-81947 13219 -50302 92935
70951 -12452 44060 -68999
68612 -63329 67331 -30225
21098 36822 -86721 85311
14179 56408 37664 -10185
-71446 -35104 -83185 -35928
62231 49184 -22420 -2128
-38074 -9...

output:

136120.859927884281
193733.837878013710
173156.721689506120
125031.883301315380
153543.349328368101
166748.475858951971
185481.061734316277
177488.089643897734
108138.479897402200
180039.829205497131
161614.879860872375
157287.764510839319
153821.044120484882
64625.572964273676
85310.078033270374
14...

result:

ok Your answer is acceptable!^ ^

Test #5:

score: 0
Accepted
time: 90ms
memory: 3828kb

input:

100000
29660 -79759 63721 -76194
73610 -35151 84824 -12411
-87524 -63981 -79091 -72979
2216 18174 -8275 -10477
43042 -7367 6840 -22825
-37089 39403 -11737 74216
-38578 -60298 -11315 -54231
-74974 27413 -80834 23157
54452 -75442 29525 -46682
-90307 -93765 -98254 -98119
-89611 -83470 -51787 -86428
527...

output:

68793.511552838592
131031.736015195902
90807.333632071425
130385.811856609835
164741.499512290302
265321.883756267725
164666.598904132363
86404.234193280378
199326.169497080299
86550.267561678466
120915.381618065548
124345.837935445477
214598.283823960831
143475.104365996320
110486.584679333332
1903...

result:

ok Your answer is acceptable!^ ^

Test #6:

score: 0
Accepted
time: 83ms
memory: 3876kb

input:

100000
-559 -590 -265 -338
671 670 -34 551
266 -278 -592 281
958 638 806 872
-34 809 -373 949
380 -847 962 -208
863 -691 927 578
-730 -913 -793 -956
-88 -133 -470 74
726 -585 769 -641
143 -383 -500 -361
836 580 434 512
-103 -967 554 -855
-226 383 -760 -57
920 749 626 979
202 392 -661 -403
-505 315 -...

output:

1299.437936549824
1601.193132405382
1669.835128627307
2480.564853759353
1560.075056334534
1443.205012183701
1303.237289383301
1042.303067379419
2227.792555225993
1408.928718704055
1608.750106929019
1105.600487276986
1662.585458445455
868.075300957536
1995.470577154286
1728.453358858273
1730.04766228...

result:

ok Your answer is acceptable!^ ^

Test #7:

score: 0
Accepted
time: 80ms
memory: 3996kb

input:

100000
20 -100 98 -47
-10 21 -100 92
26 5 23 45
-48 -22 -13 -33
85 -56 88 -92
3 26 -100 -16
90 39 53 -1
17 -55 -67 -75
-88 31 -99 14
-58 -12 -64 -10
-76 -17 -46 -79
-13 92 77 56
95 -73 19 -34
-46 38 -5 4
20 -43 79 -4
-76 84 -41 89
-58 -38 -15 -55
-97 21 -76 23
-70 -78 -32 -46
70 91 50 -18
84 -91 100...

output:

162.941379236999
81.557756457854
135.345693061346
119.442649910105
61.527864045000
146.458042047225
119.337020829467
193.000000000000
103.583566109824
131.138657489806
186.915072127435
187.308281641358
160.392049369441
89.279981273412
99.144009233241
105.385703928745
192.015154995059
154.99553589221...

result:

ok Your answer is acceptable!^ ^

Test #8:

score: 0
Accepted
time: 74ms
memory: 3880kb

input:

100000
2 7 -6 8
-9 -5 -10 -7
2 4 2 8
-3 -10 -10 -2
4 0 -3 -2
8 -7 8 -10
-7 4 -3 -4
8 -7 8 -10
-10 4 2 4
8 -10 8 -7
4 1 5 6
-7 -4 -10 -4
8 1 6 5
-1 -8 -7 -3
-9 5 -6 8
2 -1 3 -2
-9 4 -10 7
6 -9 8 -1
-1 -4 3 -4
-10 -8 -7 -10
10 2 4 4
0 -7 -4 -4
-10 2 -7 8
4 -10 -1 -3
-9 -4 -6 -5
-1 2 8 4
1 8 -4 8
-7 -1...

output:

19.418861169916
12.983351810814
12.878679656440
19.378679656440
22.378679656440
18.378679656440
13.977319491406
17.000000000000
21.169048105155
11.950490243204
13.964466094067
15.417237469702
11.980797594797
22.263932022500
13.257359312881
21.950490243204
14.480797594797
11.022750799950
18.584524052...

result:

ok Your answer is acceptable!^ ^

Extra Test:

score: 0
Extra Test Passed