# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482696 | jalsol | Odašiljači (COCI20_odasiljaci) | C++17 | 83 ms | 15972 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif
using namespace std;
const bool __initialization = []() {
cin.tie(nullptr)->sync_with_stdio(false);
#define TASK "ANGTEN"
if (fopen(TASK".inp", "r")) {
(void)(!freopen(TASK".inp", "r", stdin));
(void)(!freopen(TASK".out", "w", stdout)); }
cout << setprecision(12) << fixed;
return true;
}();
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)
template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }
constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;
// =============================================================================
constexpr int maxn = 1000 + 5;
struct Pt { int x, y; };
struct Edge {
int u, v; ld c;
bool operator<(const Edge& o) const {
return c < o.c;
}
};
int n;
Pt a[maxn];
Edge e[maxn * maxn];
int ptr;
int par[maxn];
int find(int x) {
return (par[x] < 0) ? x : (par[x] = find(par[x]));
}
bool merge(int u, int v) {
u = find(u); v = find(v);
if (u == v) return false;
if (par[v] < par[u]) swap(u, v);
par[u] += par[v];
par[v] = u;
return true;
}
ll sqr(ll x) {
return x * x;
}
ld calc(int i, int j) {
return sqrt(sqr(a[i].x - a[j].x) + sqr(a[i].y - a[j].y));
}
signed main() {
cin >> n;
For (i, 1, n) cin >> a[i].x >> a[i].y;
For (i, 1, n - 1) {
For (j, i + 1, n ) {
e[ptr++] = {i, j, calc(i, j)};
}
}
sort(e, e + ptr);
memset(par + 1, -1, sizeof(int) * n);
ld ans = 0;
Rep (i, ptr) {
if (merge(e[i].u, e[i].v)) {
ans = e[i].c;
}
}
cout << ans / 2 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |