# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
374288 | VEGAnn | Crtanje (COCI20_crtanje) | C++14 | 10 ms | 396 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;
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) << (trunc(l / 2.0 * 1e7) / 1e7);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |