Submission #374288

#TimeUsernameProblemLanguageResultExecution timeMemory
374288VEGAnnCrtanje (COCI20_crtanje)C++14
0 / 50
10 ms396 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; const ld E = 1e-9; const int N = 1010; int n, pre[N], x[N], y[N]; int get(int x) { return (pre[x] == x ? x : pre[x] = get(pre[x])); } ld sqr(ld x) { return x * x; } ld dist(int i, int j){ return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])); } bool bigger(ld x, ld y){ return (x - E > y); } bool ok(ld x){ for (int i = 0; i < n; i++) pre[i] = i; int cnt = n; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { if (!bigger(dist(i, j), x)){ if (get(i) != get(j)){ cnt--; pre[get(i)] = get(j); } } } return (cnt == 1); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; ld l = 0, r = ld(2e9); ok(0); for (int it = 0; it < 100; it++){ ld md = (l + r) / 2.0; if (ok(md)) r = md; else l = md; } cout << fixed << setprecision(7) << (trunc(l / 2.0 * 1e7) / 1e7); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...