QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563694#8081. Minimum Manhattan DistanceLiangsheng298#AC ✓92ms3956kbC++141.1kb2024-09-14 15:10:342024-09-14 15:10:34

Judging History

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

  • [2024-09-14 15:10:34]
  • 评测
  • 测评结果:AC
  • 用时:92ms
  • 内存:3956kb
  • [2024-09-14 15:10:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(){
    T x=0;char ch=getchar();bool fl=false;
    while(!isdigit(ch)){if(ch=='-')fl=true;ch=getchar();}
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);ch=getchar();
    }
    return fl?-x:x;
}
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define LL long long
#define read() read<int>()
#define LD long double
LD R1,R2,ans;
int x_1,y_1,x_2,y_2;
const LD dx[]={-1,-1,1,1};
const LD dy[]={-1,1,-1,1};
int main(){
    FASTIO;
    int T;cin>>T;
    cout<<fixed<<setprecision(9);
    while(T--){
        cin>>x_1>>y_1>>x_2>>y_2;
        LD X1=(x_1+x_2)/2.0,Y1=(y_1+y_2)/2.0,R1=sqrt(1LL*(x_2-x_1)*(x_2-x_1)+1LL*(y_2-y_1)*(y_2-y_1))/2.0;
        cin>>x_1>>y_1>>x_2>>y_2;
        LD X2=(x_1+x_2)/2.0,Y2=(y_1+y_2)/2.0,R2=sqrt(1LL*(x_2-x_1)*(x_2-x_1)+1LL*(y_2-y_1)*(y_2-y_1))/2.0;
        LD base=R2/sqrt(2);
        LD ans=1e9;
        for(int i=0;i<4;i++){
            LD x=X2+base*dx[i],y=Y2+base*dy[i];
            //cout<<x<<' '<<y<<'\n';
            ans=min(ans,fabs(x-X1)+fabs(y-Y1));
        }
        cout<<ans<<'\n';
    }
}

详细

Test #1:

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

input:

1
0 0 2 1
4 5 5 2

output:

4.263932023

result:

ok Your answer is acceptable!^ ^

Test #2:

score: 0
Accepted
time: 91ms
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.492686403
192928.302701441
227607.106035307
145831.444580046
224138.523189469
203168.416322626
106258.702187297
114459.030348489
130191.378343408
92639.995133674
110927.182439468
121482.255326367
130471.051428039
193239.869930903
101942.177602245
228879.058608113
128129.564658763
83809.4379227...

result:

ok Your answer is acceptable!^ ^

Test #3:

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

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.525110460
147100.715342061
119484.924663966
110223.186736659
130709.108038525
92808.270238245
118867.001846638
297697.871129691
213765.602167081
90968.357807112
165745.367435086
184370.169144306
184241.466886320
132742.831368450
129347.612579536
119503.626599422
155451.810031562
146746.187725...

result:

ok Your answer is acceptable!^ ^

Test #4:

score: 0
Accepted
time: 92ms
memory: 3952kb

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.859927884
193733.837878014
173156.721689506
125031.883301315
153543.349328368
166748.475858952
185481.061734316
177488.089643898
108138.479897402
180039.829205497
161614.879860872
157287.764510839
153821.044120485
64625.572964274
85310.078033270
142744.003628938
105454.524809447
151684.844681...

result:

ok Your answer is acceptable!^ ^

Test #5:

score: 0
Accepted
time: 92ms
memory: 3928kb

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.511552839
131031.736015196
90807.333632071
130385.811856610
164741.499512290
265321.883756268
164666.598904132
86404.234193280
199326.169497080
86550.267561678
120915.381618066
124345.837935445
214598.283823961
143475.104365996
110486.584679333
190341.253737206
62166.171578183
169293.722239443...

result:

ok Your answer is acceptable!^ ^

Test #6:

score: 0
Accepted
time: 81ms
memory: 3956kb

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.437936550
1601.193132405
1669.835128627
2480.564853759
1560.075056335
1443.205012184
1303.237289383
1042.303067379
2227.792555226
1408.928718704
1608.750106929
1105.600487277
1662.585458445
868.075300958
1995.470577154
1728.453358858
1730.047662280
1538.035610190
915.583636742
1269.738182215
14...

result:

ok Your answer is acceptable!^ ^

Test #7:

score: 0
Accepted
time: 76ms
memory: 3936kb

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.941379237
81.557756458
135.345693061
119.442649910
61.527864045
146.458042047
119.337020829
193.000000000
103.583566110
131.138657490
186.915072127
187.308281641
160.392049369
89.279981273
99.144009233
105.385703929
192.015154995
154.995535892
75.847918262
247.636038969
238.598387143
95.53824389...

result:

ok Your answer is acceptable!^ ^

Test #8:

score: 0
Accepted
time: 71ms
memory: 3928kb

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.418861170
12.983351811
12.878679656
19.378679656
22.378679656
18.378679656
13.977319491
17.000000000
21.169048105
11.950490243
13.964466094
15.417237470
11.980797595
22.263932023
13.257359313
21.950490243
14.480797595
11.022750800
18.584524053
4.418861170
18.878679656
18.483351811
16.792893219
15...

result:

ok Your answer is acceptable!^ ^

Extra Test:

score: 0
Extra Test Passed