# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448178 | Apiram | Odašiljači (COCI20_odasiljaci) | C++14 | 90 ms | 24752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
long double dist(pair<long double,long double>a,pair<long double,long double>b){
return hypot((a.first-b.first),(a.second-b.second))/2;
}
vector<int>parent(1e6);
vector<int>siz(1e6);
void makesets(int v){
parent[v]=v;
siz[v]=1;
}
int findsets (int v){
if (v==parent[v])return v;
parent[v]=findsets(parent[v]);
return parent[v];
}
void unionset(int a,int b){
a = findsets(a);
b =findsets(b);
if (a==b)return;
if (siz[a]<siz[b])swap(a,b);
siz[a]+=siz[b];
parent[b]=a;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
for (int i =0;i<n;++i){
makesets(i);
}
vector<pair<long double,long double>>arr(n);
for (int i = 0;i<n;++i){
cin>>arr[i].first>>arr[i].second;
}
priority_queue<pair<long double,pair<int,int>>>q;
for (int i = 0;i<n;++i){
for (int j = i+1;j<n;++j){
q.push({-dist(arr[i],arr[j]),{i,j}});
}
}
long double ans = INT_MIN;
while(true){
pair<long double,pair<int,int>>u =q.top();
q.pop();
if (findsets(u.second.first)!=findsets(u.second.second)){
unionset(u.second.first,u.second.second);
ans = max(ans,-u.first);
}
if (siz[findsets(u.second.first)]==n)break;
}
cout<<fixed<<setprecision(15)<<ans<<endl;
return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |