結果

問題 No.94 圏外です。(EASY)
ユーザー tactac
提出日時 2019-09-07 16:31:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,960 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 171,968 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 04:26:56
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


struct UnionFind {
    vector<double> data;
    int sz;
    UnionFind(int sz) : data(sz, -1) { sz = sz; }
    bool connect(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool issame(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return sz; }
};

int main() {
    
    int n;
    cin >> n;
    if (n == 0) {
        cout << 1 << '\n';
        return 0;
    }
    vector<pii> v;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        v.eb(pii(x, y));
    }
    UnionFind uni(n);
    rep(i, n) rep3(j, i + 1, n) {
        double d = sqrt((v[i].F - v[j].F) * (v[i].F - v[j].F) + (v[i].S - v[j].S) * (v[i].S - v[j].S));
        if (d > 10) continue;
        uni.connect(i, j);
    }
    double ans = 0;
    rep(i, n) rep3(j, i + 1, n) {
        if (uni.root(i) == uni.root(j)) {
            chmax(ans, sqrt((v[i].F - v[j].F) * (v[i].F - v[j].F) + (v[i].S - v[j].S) * (v[i].S - v[j].S)));
        }
    }
    cout << fixed << setprecision(7) << ans + 2 << '\n';

}
0