結果

問題 No.94 圏外です。(EASY)
ユーザー TatsuyaOba
提出日時 2016-12-18 16:29:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 66,820 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 08:25:58
合計ジャッジ時間 1,380 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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;
    }
    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]));
            }
        }
    }
    cout << sqrt(ans) + 2 << endl;
    return 0;
}

0