Submission #448178

#TimeUsernameProblemLanguageResultExecution timeMemory
448178ApiramOdašiljači (COCI20_odasiljaci)C++14
70 / 70
90 ms24752 KiB
#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 timeMemoryGrader output
Fetching results...