Submission #380161

# Submission time Handle Problem Language Result Execution time Memory
380161 2021-03-20T12:01:33 Z nguyen31hoang08minh2003 Odašiljači (COCI20_odasiljaci) C++14
70 / 70
73 ms 12908 KB
#include <bits/stdc++.h>
#define fore(i, a, b) for (ll i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (ll i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (ll i = (a), _b = (b); i >= _b; --i)
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;

template<class A, class B> bool maxi(A &a, const B &b) {return (a < b) ? (a = b, true):false;};
template<class A, class B> bool mini(A &a, const B &b) {return (a > b) ? (a = b, true):false;};

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef pair<ll, ii> Edge;

struct DisjointSet {
    std::vector<int> r;
    DisjointSet() {};
    DisjointSet(const int n): r(n, -1) {};
    void build() {
        std::fill(r.begin(), r.end(), -1);
    };
    int root(const int x) {
        return r[x] < 0 ? x : (r[x] = root(r[x]));
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (r[x] > r[y])
            std::swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
    bool connected(const int x, const int y) {
        return root(x) == root(y);
    }
    int treeSize(const int x) {
        return -r[root(x)];
    }
};

ll sqr(const ll x) {
    return x * x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    double res = 0;
    cin >> n;
    DisjointSet dsu(n);
    vi x(n), y(n);
    vector<Edge> e;
    fore(i, 0, n)
        cin >> x[i] >> y[i];
    fore(i, 1, n)
        fore(j, 0, i)
            e.pb(Edge(sqr(x[i] - x[j]) + sqr(y[i] - y[j]), ii(i, j)));
    sort(all(e));
    for (const Edge &i : e)
        if (dsu.unite(i.se.fi, i.se.se))
            res = sqrt(i.fi) / 2;
    cout << setprecision(6) << fixed << res << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 23 ms 3556 KB Output is correct
7 Correct 23 ms 3556 KB Output is correct
8 Correct 49 ms 12760 KB Output is correct
9 Correct 72 ms 12908 KB Output is correct
10 Correct 73 ms 12888 KB Output is correct