Submission #630145

#TimeUsernameProblemLanguageResultExecution timeMemory
630145Hacv16Odašiljači (COCI20_odasiljaci)C++17
70 / 70
288 ms51524 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const ld eps = 1e-7; #define pb push_back #define sz(x) (int) x.size() #define fr first #define sc second #define mp make_pair #define all(x) x.begin(), x.end() #define dbg(x) cerr << #x << ": " << "[ " << x << " ]\n" struct Antena{ int id; ld x, y; Antena(int i = 0, ld a = 0.0, ld b = 0.0){ id = i, x = a, y = b; } ld dist(Antena other){ ld dx = x - other.x, dy = y - other.y; return dx * dx + dy * dy; } }; int n, seen[MAX], cnt; vector<Antena> v; vector<int> adj[MAX]; void dfs(int u){ seen[u] = true, cnt++; for(auto v : adj[u]){ if(!seen[v]) dfs(v); } } bool check(ld d){ for(int i = 0; i < n; i++){ adj[i].clear(); seen[i] = false; } cnt = 0; for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) if(v[i].dist(v[j]) <= d * d) adj[v[i].id].pb(v[j].id), adj[v[j].id].pb(v[i].id); dfs(0); return (cnt == n); } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 0; i < n; i++){ ld x, y; cin >> x >> y; v.pb(Antena(i, x, y)); } long double l = 0, r = 1e10, ans = -1; while(r - l > eps){ ld m = (r + l) / 2.0; if(check(m)) r = m, ans = m; else l = m; } cout << setprecision(15) << fixed << ans / 2.0 << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...