# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971025 | RandomUser | Odašiljači (COCI20_odasiljaci) | C++17 | 1053 ms | 600 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;
using ll = long long;
using pii = pair<int, int>;
#define int long long
double dist(pii x, pii y) {
return sqrtl((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second));
}
struct DSU {
int n, comp;
vector<int> par, size;
void config(int _n) {
n = _n + 1;
comp = _n;
par.resize(n+1);
size.resize(n+1, 1);
for(int i=1; i<=n; i++) par[i] = i;
}
int get(int u) {
if(u == par[u]) return u;
return par[u] = get(par[u]);
}
bool uni(int u, int v) {
u = get(u), v = get(v);
if(u == v) return false;
if(size[u] < size[v]) swap(u, v);
size[u] += size[v];
par[v] = u;
comp--;
return true;
}
int getComp() { return comp; }
};
signed main() {
int n;
cin >> n;
vector<pii> v(n);
for(pii &x : v) cin >> x.first >> x.second;
double l=0.5, r=1e12, ans=1e12;
for(int it=0; it<120; it++) {
double mid = (l + r) / 2;
DSU dsu; dsu.config(n);
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(i == j) continue;
if(dist(v[i], v[j]) <= 2 * mid) dsu.uni(i, j);
}
}
if(dsu.getComp() == 1) ans = r = mid;
else l = mid;
}
cout << setprecision(8) << fixed << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |