結果

問題 No.94 圏外です。(EASY)
ユーザー noriocnorioc
提出日時 2014-12-07 21:54:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,738 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 73,556 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-02 10:58:09
合計ジャッジ時間 1,842 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define For(i,x) for (int i=0; i<(int)(x); i++)

template <class T>
T sq(T n) {
    return n*n;
}

struct Pt {
    int x, y;
    Pt(int x, int y) : x(x), y(y) {}
};

double calc(vector<Pt> & v) {

    vector< vector<Pt> > groups;

    for (int i = 0; i < v.size(); i++) {
        bool joined = false;
        const Pt& p = v[i];
        for (int j = 0; j < groups.size(); j++) {
            for (int k = 0; k < groups[j].size(); k++) {
                const Pt& q = groups[j][k];
                double d = sqrt(sq(p.x - q.x) + sq(p.y - q.y));
                if (d <= 10) {
                    groups[j].push_back(p);
                    joined = true;
                    break;
                }
            }

            if (joined) break;
        }

        if (!joined) {
            vector<Pt> newgroup;
            newgroup.push_back(p);
            groups.push_back(newgroup);
        }
    }

    double ans = 1;
    for (int i = 0; i < groups.size(); i++) {

        double d = 0;
        const vector<Pt>& g = groups[i];
        for (int j = 0; j < g.size(); j++) {
            for (int k = j+1; k < g.size(); k++) {
                double len = sqrt(sq(g[j].x - g[k].x) + sq(g[j].y - g[k].y));
                d = std::max(d, len);
            }
        }

        d += 2;
        ans = std::max(ans, d);
    }

    return ans;
}

int main() {
    int n;
    scanf("%d", &n);

    vector<Pt> v;
    For(i, n) {
        int x, y;
        scanf("%d %d", &x, &y);
        v.push_back(Pt(x, y));
    }

    printf("%lf\n", calc(v));
}
0