/**
* 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 |
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 |
106 ms |
364 KB |
Output is correct |
7 |
Correct |
106 ms |
364 KB |
Output is correct |
8 |
Correct |
233 ms |
364 KB |
Output is correct |
9 |
Correct |
351 ms |
492 KB |
Output is correct |
10 |
Correct |
310 ms |
620 KB |
Output is correct |