# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332528 | morato | Odašiljači (COCI20_odasiljaci) | C++17 | 351 ms | 620 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.
/**
* author: morato
* created: 02.12.2020 16:14:43
**/
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
double X[N], Y[N];
int p[N], rnk[N];
int n;
int find(int v) {
return p[v] == v ? v : p[v] = find(p[v]);
}
void merge(int a, int b) {
int x = find(a);
int y = find(b);
if (x != y) {
if (rnk[x] > rnk[y]) swap(x, y);
p[x] = y;
if (rnk[x] == rnk[y]) rnk[y]++;
}
}
double dist(int i, int j) {
return sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
}
bool check(double radius) {
for (int i = 1; i <= n; i++) {
p[i] = i;
rnk[i] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (dist(i, j) <= 2 * radius) {
merge(i, j);
}
}
}
set<int> st;
for (int i = 1; i <= n; i++) {
st.insert(find(i));
}
return (int) st.size() == 1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> X[i] >> Y[i];
}
double l = 0.0, r = 1e10, best = 0.0;
for (int i = 0; i < 100; i++) {
double m = (l + r) / 2.0;
if (check(m)) {
best = m;
r = m;
} else {
l = m;
}
}
cout << setprecision(10) << fixed << best << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |