# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768870 | 2023-06-28T19:47:05 Z | MilosMilutinovic | Odašiljači (COCI20_odasiljaci) | C++14 | 34 ms | 8656 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, x[N], y[N], rt[N]; struct Event { double r; int i, j; bool const operator < (const Event& ev) { return r < ev.r; } }; int root(int x) { return rt[x] == x ? x : rt[x] = root(rt[x]); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; rt[x] = y; return true; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &x[i], &y[i]); } vector<Event> ev; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { double d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]); d = sqrt(d) / 2; ev.push_back({d, i, j}); } } sort(ev.begin(), ev.end()); if (ev.empty()) { printf("0.000000"); return 0; } int comps = n; for (int i = 1; i <= n; i++) { rt[i] = i; } for (auto& p : ev) { if (unite(p.i, p.j)) { comps--; } if (comps == 1) { printf("%.6lf", p.r); return 0; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Incorrect | 1 ms | 340 KB | Output isn't correct |
5 | Incorrect | 1 ms | 468 KB | Output isn't correct |
6 | Correct | 9 ms | 2464 KB | Output is correct |
7 | Correct | 10 ms | 2504 KB | Output is correct |
8 | Correct | 28 ms | 8608 KB | Output is correct |
9 | Incorrect | 34 ms | 8656 KB | Output isn't correct |
10 | Incorrect | 34 ms | 8640 KB | Output isn't correct |