QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#386061 | #5809. Min Perimeter | zjy0001 | 0 | 0ms | 0kb | C++17 | 1.2kb | 2024-04-11 11:28:32 | 2024-04-11 11:28:32 |
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 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/2;S.erase(S.find(A[j++])));
const auto tl=S.lower_bound(make_pair((int)(A[i].first-ans/2)-1,0));
const auto tr=S.lower_bound(make_pair((int)(A[i].first+ans/2)+1,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));
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: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
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:
result:
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 ...