Submission #448178

# Submission time Handle Problem Language Result Execution time Memory
448178 2021-07-29T06:42:46 Z Apiram Odašiljači (COCI20_odasiljaci) C++14
70 / 70
90 ms 24752 KB
#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
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8140 KB Output is correct
3 Correct 4 ms 8268 KB Output is correct
4 Correct 5 ms 8300 KB Output is correct
5 Correct 5 ms 8540 KB Output is correct
6 Correct 26 ms 12352 KB Output is correct
7 Correct 26 ms 12364 KB Output is correct
8 Correct 54 ms 24708 KB Output is correct
9 Correct 86 ms 24748 KB Output is correct
10 Correct 90 ms 24752 KB Output is correct