답안 #854453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854453 2023-09-27T16:49:41 Z vjudge1 Odašiljači (COCI20_odasiljaci) C++17
70 / 70
915 ms 62968 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 100000
using namespace std;
const int mod=1000000007ll;

int c;
int parent[1000];
int find(int i){
    if(parent[i]==i){
        return i;
    }
    return parent[i]=find(parent[i]);
}
void unite(int i,int j){
    int x=find(i),y=find(j);
    if(x!=y){
        c--;
        parent[y]=x;
    }
}
#define pdd pair<double,double>
double pis(pdd&x,pdd&y){
    double X=abs(x.first-y.first);
    double Y=abs(x.second-y.second);
    return sqrt(X*X+Y*Y)/2;
}

void solve(){
    int n;
    cin>>n;
    c=n;
    for(int i=0;i<n;i++)parent[i]=i;
    pdd a[n];
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    set<pair<double,pair<int,int>>>all;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                all.insert({pis(a[i],a[j]),{i,j}});
            }
        }
    }
    double last=0;
    while(c!=1&&all.size()){
        auto p=*all.begin();
        last=p.first;
        unite(p.second.first,p.second.second);
        all.erase(p);
    }
    //cerr<<c<<"\n";
    cout<<setprecision(15)<<last<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen("in","r",stdin);
    freopen("out","w",stdout);
#endif
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 101 ms 16012 KB Output is correct
7 Correct 113 ms 15952 KB Output is correct
8 Correct 336 ms 35408 KB Output is correct
9 Correct 821 ms 62700 KB Output is correct
10 Correct 915 ms 62968 KB Output is correct