QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386070#5809. Min Perimeterzjy000120 ✓5710ms11760kbC++171.2kb2024-04-11 11:32:482024-04-11 11:32:49

Judging History

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

  • [2024-04-11 11:32:49]
  • 评测
  • 测评结果:20
  • 用时:5710ms
  • 内存:11760kb
  • [2024-04-11 11:32:48]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb double
#define uLL unsigned long long
using namespace std;
const int N=1e6+5;
const ldb INF=1e10;
int n;ldb ans;pair<int,int>A[N];
inline ldb dist(const pair<int,int>&x,const pair<int,int>&y){
    const auto [xx,xy]=x;const auto [yx,yy]=y;
    return sqrt(1ll*(xx-yx)*(xx-yx)+1ll*(xy-yy)*(xy-yy));
}
inline void MAIN(){
    cin>>n,ans=INF;
    for(int i=1;i<=n;++i)
        cin>>A[i].first>>A[i].second;
    sort(A+1,A+n+1);
    multiset<pair<int,int>>S;
    for(int i=1;i<=n;++i)swap(A[i].first,A[i].second);
    for(int i=1,j=1;i<=n;++i){
        for(;A[i].second-A[j].second>=ans;S.erase(S.find(A[j++])));
        const auto tl=S.lower_bound(make_pair((int)max(-1e9,floor(A[i].first-ans)),0));
        const auto tr=S.lower_bound(make_pair((int)min(1e9,ceil(A[i].first+ans)),0));
        for(auto a=tl;a!=tr;++a)for(auto b=tl;b!=a;++b)ans=min(ans,(dist(A[i],*a)+dist(A[i],*b)+dist(*a,*b))/2);
        S.emplace(A[i]);
    }
    cout<<fixed<<setprecision(9)<<ans*2<<'\n';
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;for(int _=1;t--;++_)
        cout<<"Case #"<<_<<": ",MAIN();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 35ms
memory: 3904kb

input:

15
3
2 6
7 0
3 0
3
713 269
371 79
455 421
3
91983245 637281504
756917015 312173515
869576338 436726680
10000
14761642 78236002
9047458 47951098
5238002 27761162
476182 2523742
1428546 7571226
26190010 138805810
21904372 116092132
18094916 95902196
43332562 229660522
55237112 292754072
52380020 27761...

output:

Case #1: 17.893012206
Case #2: 1042.844834964
Case #3: 1711142102.791327000
Case #4: 90912.296374033
Case #5: 3.414213562
Case #6: 26.153830342
Case #7: 1701.012681096
Case #8: 2865438.191993871
Case #9: 2020088.337226320
Case #10: 1792106.037292071
Case #11: 2019352.542909729
Case #12: 2530195.7280...

result:

ok correct! (15 test cases)

Subtask #2:

score: 15
Accepted

Test #2:

score: 15
Accepted
time: 5710ms
memory: 11760kb

input:

15
3
501691275 344354353
167768963 536043860
249445040 557426549
4
1000000000 0
0 0
1000000000 1000000000
0 1000000000
1000000
138925776 669369648
61257680 295150640
170762328 822763944
55483472 267329456
97736936 470914328
84041848 404928904
18463588 88960924
124429360 599523280
95066048 458045504
...

output:

Case #1: 799653579.133089781
Case #2: 3414213562.373095036
Case #3: 866.071590574
Case #4: 62459.895369637
Case #5: 59141.918358932
Case #6: 898195.090968268
Case #7: 1707085.769986785
Case #8: 1686.226798258
Case #9: 1686.603545972
Case #10: 6806.665583936
Case #11: 1907363.078325002
Case #12: 1798...

result:

ok correct! (15 test cases)

Extra Test:

score: 0
Extra Test Passed