제출 #474038

#제출 시각아이디문제언어결과실행 시간메모리
474038mychecksedadOdašiljači (COCI20_odasiljaci)C++17
70 / 70
262 ms4652 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back const int N = 1010, F = 1e9; int n; struct P{ ll x, y; double dist(P a){ return sqrt((x - a.x) * (x - a.x) + (y - a.y) * (y - a.y)); } }; bool check(vector<vector<int>> &g){ queue<int> q; vector<bool> v(1001, 0); q.push(0); v[0] = 1; while(!q.empty()){ int x = q.front(); q.pop(); for(int u: g[x]){ if(!v[u]){ v[u] = 1; q.push(u); } } } bool ok = 1; for(int i=0;i<n;i++) ok&=v[i]; return ok; } int main(){ cin.tie(0); ios::sync_with_stdio(0); P arr[N]; cin >> n; for(int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y; double l = 0, r = 2*F, ans = 2*F; while(l + (0.000001f) < r){ double mid = (l+r)/2.0; vector<vector<int>> g(N); for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ double d = arr[i].dist(arr[j]); if(d <= mid){ g[i].pb(j); g[j].pb(i); } } } if(check(g)){ ans = min(ans, mid); r = mid; }else l = mid; } cout << fixed << setprecision(15); cout << l/2.0; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...