Submission #1108937

# Submission time Handle Problem Language Result Execution time Memory
1108937 2024-11-05T17:15:26 Z Dreamy_lovesper Odašiljači (COCI20_odasiljaci) C++17
70 / 70
763 ms 8480 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
ll calc(ll x ,ll y){
    return abs(x - y) * abs(x-y);
}
int n;
vector<bool>vis;
vector<vector<ll>>a((1e3) + 5,vector<ll>(int(1e3) + 5));
int cnt =0;
void dfs(int idx,ld mid){
    if(vis[idx])
    {
        return;
    }
    vis[idx] = 1;
    for(int i=0;i<n;i++){
        if(i == idx)continue;
        if((ld)sqrt(a[idx][i]) > mid)continue;
        dfs(i,mid);
    }
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    vis.resize(n);
    vector<pair<ll,ll>>v;
    for(int i=0;i<n;i++){
        ll x,y;cin >> x >> y;
        v.push_back({x,y});
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i == j)continue;
            a[i][j] = calc(v[i].first,v[j].first) + calc(v[i].second,v[j].second);
        }   
    }
    ld l = 0.0000000000;
    ld r = 2e18;
    ld ans =0.00000000000;
    for(int i=0;i<100;i++){
        ld mid = (r+l)/2;
        vis = vector<bool>(n);
        dfs(0,mid);
        bool f= false;
        for(int j=0;j<n;j++){
            if(vis[j] == 0)
            {
                f = true;
                break;
            }
        }
        if(!f){
            r = mid;
            ans = mid;
        }else{
            l = mid;
        }
    }
    cout << fixed << setprecision(10) << ans / 2 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8272 KB Output is correct
2 Correct 7 ms 8272 KB Output is correct
3 Correct 9 ms 8272 KB Output is correct
4 Correct 10 ms 8296 KB Output is correct
5 Correct 13 ms 8444 KB Output is correct
6 Correct 187 ms 8272 KB Output is correct
7 Correct 204 ms 8272 KB Output is correct
8 Correct 445 ms 8272 KB Output is correct
9 Correct 763 ms 8480 KB Output is correct
10 Correct 627 ms 8272 KB Output is correct