#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const ld E = 1e-9;
const int N = 1010;
int n, pre[N], x[N], y[N];
int get(int x) { return (pre[x] == x ? x : pre[x] = get(pre[x])); }
ld sqr(ld x) { return x * x; }
ld dist(int i, int j){
return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
}
bool bigger(ld x, ld y){
return (x - E > y);
}
bool ok(ld x){
for (int i = 0; i < n; i++)
pre[i] = i;
int cnt = n;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
if (!bigger(dist(i, j), x)){
if (get(i) != get(j)){
cnt--;
pre[get(i)] = get(j);
}
}
}
return (cnt == 1);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i];
ld l = 0, r = ld(2e9);
ok(0);
for (int it = 0; it < 100; it++){
ld md = (l + r) / 2.0;
if (ok(md))
r = md;
else l = md;
}
cout << fixed << setprecision(7) << l / 2.0;
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 |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
364 KB |
Output is correct |
5 |
Correct |
7 ms |
364 KB |
Output is correct |
6 |
Correct |
169 ms |
492 KB |
Output is correct |
7 |
Correct |
170 ms |
492 KB |
Output is correct |
8 |
Correct |
365 ms |
492 KB |
Output is correct |
9 |
Correct |
595 ms |
492 KB |
Output is correct |
10 |
Correct |
554 ms |
492 KB |
Output is correct |