QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#385225#5809. Min Perimeterzjy00010 10885ms17148kbC++172.3kb2024-04-10 16:41:272024-04-10 16:41:27

Judging History

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

  • [2024-04-10 16:41:27]
  • 评测
  • 测评结果:0
  • 用时:10885ms
  • 内存:17148kb
  • [2024-04-10 16:41:27]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long 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 int&x,const int&y){
    const auto [xx,xy]=A[x];const auto [yx,yy]=A[y];
    return sqrtl(1ll*(xx-yx)*(xx-yx)+1ll*(xy-yy)*(xy-yy));
}
inline void solve(int l,int r){
    if(r-l<2){
        sort(A+l,A+r+1,[&](const pair<int,int>&x,const pair<int,int>&y){
            return x.second<y.second;
        });
        return;
    }
    const int mid=(l+r)>>1;
    solve(l,mid),solve(mid+1,r);
    const int lx=max_element(A+l,A+mid+1)->first;
    const int rx=min_element(A+mid+1,A+r+1)->first;
    vector<int>S;
    for(int i=l,lp=mid+1,rp=mid+1;i<=mid;++i)
        if(rx-A[i].first<ans){
            for(;rp<=r&&A[rp].second-A[i].second<ans;++rp)
                if(A[rp].first-lx<ans)S.emplace_back(rp);
            for(;lp<rp&&A[i].second-A[lp].second>=ans;++lp);
            vector<int>T;
            for(auto j:S)if(j>=lp&&A[j].first-lx<ans)T.emplace_back(j);
            S=move(T);
            for(auto j:S)for(auto k:S)
                if(k<j)ans=min(ans,(dist(i,j)+dist(j,k)+dist(i,k))/2);
                else break;
        }
    S.clear();
    for(int i=mid+1,lp=l,rp=l;i<=r;++i)
        if(A[i].first-lx<ans){
            for(;rp<=mid&&A[rp].second-A[i].second<ans;++rp)
                if(rx-A[rp].first<ans)S.emplace_back(rp);
            for(;lp<rp&&A[i].second-A[lp].second>=ans;++lp);
            vector<int>T;
            for(auto j:S)if(j>=lp&&A[j].first-lx<ans)T.emplace_back(j);
            S=move(T);
            for(auto j:S)for(auto k:S)
                if(k<j)ans=min(ans,(dist(i,j)+dist(j,k)+dist(i,k))/2);
                else break;
        }
    inplace_merge(A+l,A+mid+1,A+r+1,[&](const pair<int,int>&x,const pair<int,int>&y){
        return x.second<y.second;
    });
}
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),solve(1,n);
    cout<<fixed<<setprecision(12)<<ans<<'\n';
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;for(int _=1;t--;++_)
        cout<<"Case #"<<_<<": ",MAIN();
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 60ms
memory: 4076kb

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: 8.946506103102
Case #2: 521.422417482194
Case #3: 855571051.395663553907
Case #4: 45456.148187016462
Case #5: 1.707106781187
Case #6: 13.076915171082
Case #7: 850.506340547808
Case #8: 1432719.095996935550
Case #9: 1010044.168613159841
Case #10: 896053.018646035570
Case #11: 1009676.2714548...

result:

wrong answer read 8.946506103102 but expected 17.893012206205 (test case 1)

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 10885ms
memory: 17148kb

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: 399826789.566544870875
Case #2: 1707106781.186547524412
Case #3: 433.035795287179
Case #4: 31229.947684818574
Case #5: 29570.959179465891
Case #6: 449097.545484133997
Case #7: 853542.884993392527
Case #8: 843.113399129068
Case #9: 843.301772985818
Case #10: 3403.332791968146
Case #11: 95368...

result:

wrong answer read 399826789.566544890404 but expected 799653579.133089780807 (test case 1)