Submission #674716

# Submission time Handle Problem Language Result Execution time Memory
674716 2022-12-26T01:00:21 Z rafatoa Odašiljači (COCI20_odasiljaci) C++17
70 / 70
70 ms 352 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
 
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define ppb pop_back
#define read(a) for(auto &x:a) cin >> x;
#define print(a) for(auto x:a) cout << x << " "; cout << "\n";
#define vc vector<char>
#define vvc vector<vc>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
#define int long long
#define ld long double
const int INF = 1e18;
const int inf = 1e9;

struct DSU{
    vi link, sz;
    DSU(int n){
        link = sz = vi(n);
        for(int i=0; i<n; i++)
            link[i] = i, sz[i] = 1;
    }
    int find(int x){
        if(x == link[x]) return x;
        return link[x] = find(link[x]);
    }
    bool same(int a, int b){
        return find(a) == find(b);
    }
    void unite(int a, int b){
        a = find(a), b = find(b);
        if(a == b) return;
        if(sz[a] < sz[b]) swap(a, b);
        link[b] = a;
        sz[a] += sz[b];
    }
};

ld eps = 1e-6;
 
void solve(){
    int n; cin >> n;
    vi x(n), y(n);
    for(int i=0; i<n; i++)
        cin >> x[i] >> y[i];
    
    ld l = 0, r = 2e9, k;
    while(r-l >= eps){
        k = (l+r)/2;

        DSU dsu(n);
        for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            if((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) <= k*k*4)
                dsu.unite(i, j);
        
        bool ok = 1;
        for(int i=0; i<n && ok; i++)
            ok &= (dsu.sz[dsu.find(i)] == n);
        
        if(ok) r = k;
        else l = k;
    }
    cout << fixed << setprecision(20) << l << "\n";
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif
 
    int tt = 1;
    // cin >> tt;
    while(tt--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 25 ms 212 KB Output is correct
7 Correct 24 ms 340 KB Output is correct
8 Correct 51 ms 340 KB Output is correct
9 Correct 70 ms 340 KB Output is correct
10 Correct 58 ms 352 KB Output is correct