Submission #854458

# Submission time Handle Problem Language Result Execution time Memory
854458 2023-09-27T16:53:23 Z vjudge1 Odašiljači (COCI20_odasiljaci) C++17
70 / 70
57 ms 14788 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 1e3+1;
vi dad(N);

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

void unite(int x,int y) {
	dad[find(x)] = find(y);
}

void solve() {
	int n;
	cin >> n;
	vector<pair<pii,double>> edg;
	vi x(n+1),y(n+1);
	for (int i=1;i<=n;i++) cin >> x[i] >> y[i];
	for (int i=1;i<=n;i++) {
		for (int j=i+1;j<=n;j++) {
			int dx = x[i]-x[j];
			int dy = y[i]-y[j];
			edg.pb({{i,j},sqrtl(dx*dx+dy*dy)});
		}
	}
	double l = 0;
	double r = 1e9;
	double eps = 1e-8;
	cout << setprecision(12);
	while (l<=r) {
		double v = (l+r)/2;
		for (int i=1;i<=n;i++) dad[i] = i;;
		for (auto it : edg) {
			if (it.second <= 2*v) {
				unite(it.first.first,it.first.second);
			}
		}
		int c = 1;
		for (int i=1;i<=n;i++) c&=(find(i) == find(1)); 
		if (c) r = v-eps;
		else l = v+eps;
	}
	cout << l << endl;
}     
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 728 KB Output is correct
6 Correct 23 ms 4816 KB Output is correct
7 Correct 23 ms 3536 KB Output is correct
8 Correct 49 ms 14280 KB Output is correct
9 Correct 57 ms 14788 KB Output is correct
10 Correct 35 ms 13612 KB Output is correct