QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#385057#5809. Min Perimeterzjy00010 201ms4020kbC++172.2kb2024-04-10 15:07:282024-04-10 15:07:28

Judging History

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

  • [2024-04-10 15:07:28]
  • 评测
  • 测评结果:0
  • 用时:201ms
  • 内存:4020kb
  • [2024-04-10 15:07:28]
  • 提交

answer

#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(1.l*(xx-yx)*(xx-yx)+1.l*(xy-yy)*(xy-yy));
}
inline void solve(int l,int r){
    if(r-l<2)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;
    set<int>S;
    for(int i=l,lp=mid+1,rp=mid+1;i<=mid;++i)
        if((rx-A[i].first)*2.<ans){
            for(;rp<=r&&(A[rp].second-A[i].second)*2.<ans;++rp)
                if((A[rp].first-lx)*2.<ans)S.emplace(rp);
            for(;lp<rp&&(A[i].second-A[lp].second)*2.>=ans;++lp)S.erase(lp);
            set<int>T;
            for(auto j:S)if(fabs(A[j].first-lx)*2.<ans)T.emplace(j);
            S=T;
            for(auto j:S)for(auto k:S)
                if(k<j)ans=min(ans,dist(i,j)+dist(j,k)+dist(i,k));
                else break;
        }
    S.clear();
    for(int i=mid+1,lp=l,rp=l;i<=r;++i)
        if((A[i].first-lx)*2.<ans){
            for(;rp<=mid&&(A[rp].second-A[i].second)*2.<ans;++rp)
                if((rx-A[rp].first)*2.<ans)S.emplace(rp);
            for(;lp<rp&&(A[i].second-A[lp].second)*2.>=ans;++lp)S.erase(lp);
            set<int>T;
            for(auto j:S)if(fabs(rx-A[j].first)*2.<ans)T.emplace(j);
            S=T;
            for(auto j:S)for(auto k:S)
                if(k<j)ans=min(ans,dist(i,j)+dist(j,k)+dist(i,k));
                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: 201ms
memory: 4020kb

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.893012206205
Case #2: 1042.844834964388
Case #3: 1711142102.791327107698
Case #4: 90912.296374032924
Case #5: 3.414213562373
Case #6: 27.922464265531
Case #7: 3124.810897651864
Case #8: 3936505.776763414336
Case #9: 2757507.029736536686
Case #10: 2313952.129338373068
Case #11: 2205610.91...

result:

wrong answer read 27.922464265531 but expected 26.153830342164 (test case 6)

Subtask #2:

score: 0
Time Limit Exceeded

Test #2:

score: 0
Time Limit Exceeded

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:


result: