結果

問題 No.94 圏外です。(EASY)
ユーザー naimonon77naimonon77
提出日時 2016-09-25 18:24:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 1,551 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 167,692 KB
実行使用メモリ 7,212 KB
最終ジャッジ日時 2023-09-08 14:59:40
合計ジャッジ時間 2,877 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,036 KB
testcase_01 AC 3 ms
7,036 KB
testcase_02 AC 3 ms
6,924 KB
testcase_03 AC 3 ms
6,928 KB
testcase_04 AC 4 ms
7,048 KB
testcase_05 AC 5 ms
6,928 KB
testcase_06 AC 7 ms
6,908 KB
testcase_07 AC 10 ms
6,976 KB
testcase_08 AC 18 ms
7,036 KB
testcase_09 AC 32 ms
6,964 KB
testcase_10 AC 32 ms
6,868 KB
testcase_11 AC 31 ms
6,920 KB
testcase_12 AC 32 ms
7,028 KB
testcase_13 AC 32 ms
6,908 KB
testcase_14 AC 33 ms
6,912 KB
testcase_15 AC 33 ms
7,040 KB
testcase_16 AC 33 ms
6,916 KB
testcase_17 AC 33 ms
7,212 KB
testcase_18 AC 33 ms
6,868 KB
testcase_19 AC 28 ms
6,980 KB
testcase_20 AC 4 ms
6,984 KB
testcase_21 AC 3 ms
7,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int N;
double x[1005], y[1005];

void solve() {
	UnionFind uf((int)1e6);
	double ans = 0;
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	rep(i, N) rep(j, N) {
		if (hypot(x[i] - x[j], y[i] - y[j]) - 1e-6 < 10) {
			uf.unite(i, j);
		}
		// dump(hypot(x[i] - x[j], y[i] - y[j]));
	}
	rep(i, N) rep(j, N) {
		if (uf.same(i, j)) {
			ans = max(ans, hypot(x[i] - x[j], y[i] - y[j]));
		}
	}
	if (N == 0) puts("1");
	else {
		ans += 2;
		printf("%.20lf\n", ans);
	}
}

signed main() {
	while (cin >> N) {
		solve();
	}
	return 0;
}
0