結果

問題 No.94 圏外です。(EASY)
ユーザー TatsuyaObaTatsuyaOba
提出日時 2016-12-18 16:40:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,428 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 65,796 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 15:02:51
合計ジャッジ時間 1,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>

using namespace std;

class Pos {
public:
    int x;
    int y;
    Pos() {

    }
    Pos(int x, int y) {
        this->x = x;
        this->y = y;
    }
    int distance(Pos pos) {
        return (x - pos.x) * (x - pos.x) + (y - pos.y) * (y - pos.y);
    }
};


bool check[1000];
Pos all_pos[1000];
int N;

void foo(int index, vector<Pos> &poss) {
    for (int i = 0; i < N; i++) {
        if (check[i]) {
            continue;
        }
        int distance = all_pos[index].distance(all_pos[i]);
        if (distance <= 100) {
            check[i] = true;
            poss.push_back(all_pos[i]);
            foo(i, poss);
        }
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        check[i] = false;
    }
    if (N == 0) {
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        all_pos[i] = Pos(x, y);
    }
    for (int i = 0; i < N; i++) {
        if (check[i]) {
            continue;
        }
        vector<Pos> poss;
        poss.push_back(all_pos[i]);
        foo(i, poss);
        for (int j = 0; j < poss.size(); j++) {
            for (int k = j; k < poss.size(); k++) {
                ans = max(ans, poss[j].distance(poss[k]));
            }
        }
    }
    printf("%10f\n", sqrt(ans) + 2);
    return 0;
}

0