結果

問題 No.94 圏外です。(EASY)
ユーザー ふーらくたるふーらくたる
提出日時 2016-09-23 02:23:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 870 ms / 5,000 ms
コード長 1,140 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 68,300 KB
実行使用メモリ 4,680 KB
最終ジャッジ日時 2023-09-08 15:00:25
合計ジャッジ時間 10,753 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 35 ms
4,376 KB
testcase_07 AC 108 ms
4,380 KB
testcase_08 AC 307 ms
4,384 KB
testcase_09 AC 779 ms
4,624 KB
testcase_10 AC 781 ms
4,680 KB
testcase_11 AC 780 ms
4,504 KB
testcase_12 AC 777 ms
4,508 KB
testcase_13 AC 780 ms
4,500 KB
testcase_14 AC 785 ms
4,516 KB
testcase_15 AC 782 ms
4,652 KB
testcase_16 AC 782 ms
4,660 KB
testcase_17 AC 788 ms
4,452 KB
testcase_18 AC 781 ms
4,660 KB
testcase_19 AC 870 ms
4,512 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

const int MAX_N = 1010;

int x[MAX_N], y[MAX_N];
bool connected[MAX_N][MAX_N];

int square_dist(int x1, int y1, int x2, int y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

int main() {
    int n;
    cin >> n;

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int d = square_dist(x[i], y[i], x[j], y[j]);
            if (d <= 10 * 10) connected[i][j] = true;
        }
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                connected[i][j] |= connected[i][k] && connected[k][j];
            }
        }
    }
    double ans = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (connected[i][j]) {
                double dist = sqrt(square_dist(x[i], y[i], x[j], y[j]));
                ans = max(ans, dist + 2.0);
            }
        }
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}
0