Submission #374288

# Submission time Handle Problem Language Result Execution time Memory
374288 2021-03-07T06:55:11 Z VEGAnn Crtanje (COCI20_crtanje) C++14
0 / 50
10 ms 396 KB
#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
1 Incorrect 10 ms 396 KB Output isn't correct
2 Incorrect 9 ms 364 KB Output isn't correct
3 Incorrect 9 ms 364 KB Output isn't correct
4 Incorrect 9 ms 364 KB Output isn't correct
5 Incorrect 9 ms 364 KB Output isn't correct