結果

問題 No.94 圏外です。(EASY)
ユーザー kimiyukikimiyuki
提出日時 2016-02-18 22:43:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,150 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 80,800 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 06:47:35
合計ジャッジ時間 1,795 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <math.h>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
template <typename T> bool setmax(T & l, T const & r) { if (not (l < r)) return false; l = r; return true; }
using namespace std;
int sq(int x) { return x * x; }
int main() {
    int n; cin >> n;
    vector<int> x(n), y(n); repeat (i,n) cin >> x[i] >> y[i];
    if (n == 0) {
        cout << 1 << endl;
        return 0;
    }
    vector<vector<bool> > g(n, vector<bool>(n));
    repeat (i,n) repeat (j,n) {
        g[i][j] = (sq(y[j] - y[i]) + sq(x[j] - x[i]) <= 100);
    }
    vector<bool> used(n);
    function<void (int, vector<int> &)> dfs = [&](int i, vector<int> & acc) {
        used[i] = true;
        acc.push_back(i);
        repeat (j,n) if (g[i][j] and not used[j]) dfs(j, acc);
    };
    double ans = 0;
    repeat (i,n) if (not used[i]) {
        vector<int> acc;
        dfs(i, acc);
        for (int j : acc) for (int k : acc) {
            setmax(ans, sqrt(sq(y[k] - y[j]) + sq(x[k] - x[j])));
        }
    }
    printf("%.12lf\n", ans + 2);
    return 0;
}
0