답안 #374294

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374294 2021-03-07T07:08:09 Z Vimmer Odašiljači (COCI20_odasiljaci) C++14
70 / 70
433 ms 492 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")

#define N 1005
#define NN 1005000
#define PB push_back
#define M ll(1e9 + 7)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define pri(x) cout << x << endl
#define endl '\n'
#define _ << " " <<
#define F first
#define S second

using namespace std;
//using namespace __gnu_pbds;

//typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> oredered_set;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef short int si;

int n, pr[N];

int fnd(int x)
{
    if (pr[x] != x)
        pr[x] = fnd(pr[x]);

    return pr[x];
}

void link(int a, int b)
{
    a = fnd(a); b = fnd(b);

    if (a == b) return;

    pr[b] = a;
}

int x[N], y[N];

ld eps = 1e-16;

bool gd(ld r)
{
    r += r;

    r *= r;

    for (int i = 0; i < n; i++)
        pr[i] = i;

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            ld rst = 1ll * (x[i] - x[j]) * (x[i] - x[j]) + 1ll * (y[i] - y[j]) * (y[i] - y[j]);

            if (r - rst >= eps)
                link(i, j);
        }

    for (int i = 1; i < n; i++)
        if (fnd(i) != fnd(0))
            return 0;

    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("1.in", "r", stdin);

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    ld l = 0, r = 100 * 1e9;

    int c = 150;

    while (c)
    {
        c--;

        ld md = (l + r) / 2.0;

        if (gd(md))
            r = md;
                else l = md;
    }

    cout << setprecision(7) << fixed;
    ld ep = 1e-7;

    l /= ep;

    r = ll(l);

    l = r;

    l /= 1e7;


    pri(l);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 6 ms 380 KB Output is correct
6 Correct 135 ms 492 KB Output is correct
7 Correct 135 ms 492 KB Output is correct
8 Correct 298 ms 364 KB Output is correct
9 Correct 433 ms 364 KB Output is correct
10 Correct 387 ms 492 KB Output is correct