結果

問題 No.94 圏外です。(EASY)
ユーザー xuzijian629xuzijian629
提出日時 2018-10-29 18:20:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,436 bytes
コンパイル時間 2,551 ms
コンパイル使用メモリ 206,092 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:07:25
合計ジャッジ時間 9,970 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 78 ms
5,376 KB
testcase_10 AC 142 ms
5,376 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 112 ms
5,376 KB
testcase_13 AC 55 ms
5,376 KB
testcase_14 AC 219 ms
5,376 KB
testcase_15 AC 151 ms
5,376 KB
testcase_16 AC 336 ms
5,376 KB
testcase_17 AC 171 ms
5,376 KB
testcase_18 AC 214 ms
5,376 KB
testcase_19 TLE -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

vi par;
int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return true;
    par[x] = y;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    vi xs(n), ys(n);
    for (int i = 0; i < n; i++) {
        cin >> xs[i] >> ys[i];
    }

    par = vi(n);
    iota(par.begin(), par.end(), 0);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            i64 d = i64(xs[i] - xs[j]) * (xs[i] - xs[j]) + i64(ys[i] - ys[j]) * (ys[i] - ys[j]);
            if (d <= 10 * 10) {
                unite(i, j);
            }
        }
    }

    double ans = 1;
    for (int i = 0; i < n; i++) {
        find(i);
    }
    
    for (int i = 0; i < n; i++) {
        vi ps;
        for (int j = 0; j < n; j++) {
            if (par[i] == par[j]) ps.push_back(j);
        }
        double d = 0;
        for (int j = 0; j < ps.size(); j++) {
            for (int k = j + 1; k < ps.size(); k++) {
                d = max(d, hypot(xs[ps[k]] - xs[ps[j]], ys[ps[k]] - ys[ps[j]]));
            }
        }
        ans = max(ans, d + 2);
    }
    cout << ans << endl;
}
0