답안 #328548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328548 2020-11-17T04:46:15 Z nandonathaniel Odašiljači (COCI20_odasiljaci) C++14
70 / 70
483 ms 492 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1005;

long double x[MAXN],y[MAXN];
int par[MAXN];

int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}

void join(int a,int b){
	par[find(a)]=find(b);
}

long double jarak(long double a,long double b,long double c,long double d){
	return sqrt((c-a)*(c-a)+(d-b)*(d-b));
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> x[i] >> y[i];
	}
	long double ki=0,ka=2e9;
	for(int it=1;it<=60;it++){
		long double mid=(ki+ka)/2.0;
		for(int i=1;i<=n;i++)par[i]=i;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(jarak(x[i],y[i],x[j],y[j])<=2.0*mid){
					join(i,j);
				}
			}
		}
		int cc=0;
		for(int i=1;i<=n;i++){
			if(find(i)==i)cc++;
		}
		if(cc==1){
			ka=mid;
		}
		else ki=mid;
	}
	cout << fixed << setprecision(9) << ka << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 5 ms 364 KB Output is correct
6 Correct 149 ms 492 KB Output is correct
7 Correct 147 ms 492 KB Output is correct
8 Correct 329 ms 492 KB Output is correct
9 Correct 483 ms 364 KB Output is correct
10 Correct 418 ms 420 KB Output is correct