답안 #872103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872103 2023-11-12T10:12:17 Z SalihSahin Odašiljači (COCI20_odasiljaci) C++17
70 / 70
94 ms 480 KB
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long 
using namespace std;

const int N = 1e3 + 5;
const int mod = 1e9+7;

int par[N];

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

bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return 0;

    par[b] = a;
    return 1;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<double, double> > a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i].first>>a[i].second;
    }

    double diff = 1e-7;
    double l = 0, r = 1e10;
    while(l + diff < r){
        double mid = (l + r)/2;

        int g = n;
        for(int i = 0; i < n; i++) par[i] = i;

        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                double dis = sqrt((a[i].first - a[j].first)*(a[i].first - a[j].first) + (a[i].second - a[j].second)*(a[i].second - a[j].second));
                if(mid * 2 >= dis){
                    g -= merge(i, j);
                }
            }
        }

        if(g == 1){
            r = mid;
        }
        else l = mid;
    }

    printf("%.7f \n", l);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 23 ms 480 KB Output is correct
7 Correct 24 ms 348 KB Output is correct
8 Correct 55 ms 344 KB Output is correct
9 Correct 92 ms 348 KB Output is correct
10 Correct 94 ms 348 KB Output is correct