제출 #496109

#제출 시각아이디문제언어결과실행 시간메모리
496109AlperenTOdašiljači (COCI20_odasiljaci)C++17
70 / 70
452 ms336 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e3 + 5;

int n;

pair<int, int> arr[N];

long double l, r, m, x, y;

struct DSU{
    int par[N], stsize[N], setcnt;

    void reset(int n){
        for(int i = 1; i <= n; i++) par[i] = i, stsize[i] = 1;
        setcnt = n;
    }

    int setfind(int a){
        if(par[a] == a) return a;
        else return par[a] = setfind(par[a]);
    }

    void setunion(int a, int b){
        a = setfind(a), b = setfind(b);

        if(a != b){
            if(stsize[b] > stsize[a]) swap(a, b);
            par[b] = par[a];
            stsize[a] += stsize[b];
            setcnt--;
        }
    }
};

DSU dsu;

bool check(long double m){
    dsu.reset(n);

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            x = abs(arr[i].first - arr[j].first), y = abs(arr[i].second - arr[j].second);

            if(m >= sqrt(x * x + y * y) / 2) dsu.setunion(i, j);
        }
    }

    return dsu.setcnt == 1;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n;

    for(int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second;

    l = 0 - 1e-9, r = 1e12;

    for(int i = 0; i < 100; i++){
        m = l + (r - l) / 2;

        if(check(m)) r = m;
        else l = m;
    }

    cout << setprecision(12) << r;
}
#Verdict Execution timeMemoryGrader output
Fetching results...