結果

問題 No.94 圏外です。(EASY)
ユーザー pekempeypekempey
提出日時 2015-08-18 16:36:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 1,499 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 157,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 14:35:41
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

struct UF {
	vector<int> parent, size;
	UF(int n) : parent(n), size(n, 1) {
		rep (i, n) parent[i] = i;
	}
	int root(int x) {
		if (x == parent[x]) return x;
		else return parent[x] = root(parent[x]);
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (size[x] > size[y]) swap(x, y);
		size[x] += size[y];
		parent[y] = x;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

typedef double D;
typedef complex<D> P;
const D eps = 1e-8;

D dot(P a, P b) {
	return real(conj(a) * b);
}

D cross(P a, P b) {
	return imag(conj(a) * b);
}

int N;
P ps[1000];

double G[1000][1000];

int main() {
	int N;
	cin >> N;
	rep (i, N) {
		double x, y;
		cin >> x >> y;
		ps[i] = P(x, y);
	}

	UF uf(N);

	rep (i, N) rep (j, N) {
		if (abs(ps[j] - ps[i]) <= 10) {
			uf.unite(i, j);	
		}
	}

	map<int, vector<int>> group;

	rep (i, N) {
		group[uf.root(i)].push_back(i);
	}

	double ans = 1;

	for (auto q : group) {
		vector<int> p = q.second;
		double dist = 0;
		rep (i, p.size()) {
			rep (j, p.size()) {
				dist = max(dist, abs(ps[p[j]] - ps[p[i]]));
			}
		}
		ans = max(ans, dist + 2);
	}

	printf("%.20f\n", ans);

	return 0;
}
0