結果

問題 No.96 圏外です。
ユーザー motumotumotumotu
提出日時 2014-12-07 22:14:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,622 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 78,176 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-02 11:01:13
合計ジャッジ時間 23,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 22 ms
4,380 KB
testcase_05 AC 58 ms
4,380 KB
testcase_06 AC 143 ms
4,380 KB
testcase_07 AC 384 ms
4,380 KB
testcase_08 AC 646 ms
4,380 KB
testcase_09 AC 1,282 ms
4,384 KB
testcase_10 AC 3,495 ms
4,380 KB
testcase_11 AC 4,210 ms
4,488 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-10
#define PI  (acos(-1))
#define INF 10000000
struct edge { int to; int cost; };
//===================================================
double n, x[120000], y[120000];

class UnionFind {
    int par[120000];
    int rank[120000];
public :
    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

double twoPointDistance(int xa, int ya, int xb, int yb) {
    return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
}

int main()
{
    UnionFind uf;
    cin >> n;
    uf.init(n);
    REP(i, n) {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            //cout << twoPointDistance(x[i], y[i], x[j], y[j]) << endl;
            if (twoPointDistance(x[i], y[i], x[j], y[j]) <= 10) {
                uf.unite(i, j);
            }
        }
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (uf.same(i, j)) {
                double t = twoPointDistance(x[i], y[i], x[j], y[j]);
                if (t > ans) {
                    ans = t;
                }
            }
        }
    }
    
    printf("%.10f\n", (n) ? ans + 2 : 1);

    return 0;
}
0