結果

問題 No.94 圏外です。(EASY)
ユーザー tea_pttea_pt
提出日時 2015-06-12 21:21:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 2,288 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 90,796 KB
実行使用メモリ 11,576 KB
最終ジャッジ日時 2023-09-08 14:29:40
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 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 3 ms
4,384 KB
testcase_05 AC 3 ms
4,748 KB
testcase_06 AC 5 ms
7,276 KB
testcase_07 AC 7 ms
7,600 KB
testcase_08 AC 9 ms
9,648 KB
testcase_09 AC 16 ms
11,428 KB
testcase_10 AC 16 ms
11,344 KB
testcase_11 AC 17 ms
11,356 KB
testcase_12 AC 16 ms
11,488 KB
testcase_13 AC 16 ms
11,524 KB
testcase_14 AC 16 ms
11,464 KB
testcase_15 AC 17 ms
11,372 KB
testcase_16 AC 15 ms
11,464 KB
testcase_17 AC 16 ms
11,572 KB
testcase_18 AC 16 ms
11,376 KB
testcase_19 AC 14 ms
11,576 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <complex>


#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#if defined(_MSC_VER)||__cplusplus > 199711L
#define AUTO(r,v) auto r = (v)
#else
#define AUTO(r,v) typeof(v) r = (v)
#endif
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(AUTO(it,(c).begin());it != (c).end();++it)
#define LL long long
#define int LL
#define INF  999999999999
#define DEV 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
using namespace std;


class UnionFind{
public:
	//nは要素数
	UnionFind(int n) :
		par(n),
		rank(n)
	{
		for (int i = 0; i < n; ++i){
			par[i] = i;
		}
	}

	//xとyの属する集合を結合
	void unite(int x, int y){
		x = find(x);
		y = find(y);

		if (x == y)return;

		if (rank.at(x) < rank.at(y)){
			par.at(x) = y;
		}
		else{
			par.at(y) = x;
			if (rank.at(x) == rank.at(y))rank.at(x)++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}

private:
	//親
	vector<int> par;

	//根の深さ
	vector<int> rank;

	//木の根を求める
	int find(int x){
		if (par.at(x) == x){
			return x;
		}
		else{
			return par.at(x) = find(par.at(x));
		}
	}
};

int d[1002][1002];

complex<int> p[1002];


int n;

bool solve(int mu){
	UnionFind uf(n);

	REP(i, n){
		REP(j, n){
			if (d[i][j] <= mu ){
				uf.unite(i, j);
			}
		}
	}

	return uf.same(0, n - 1);
}

signed main()
{
	QUICK_CIN;
	//ifstream cin("debug.txt");
	//ofstream cout("result.txt");


	cin >> n;

	REP(i, n){
		int x, y;
		cin >> x >> y;

		p[i] = { (int)x, (int)y };
	}

	REP(i, n){
		REP(j, n){
			d[i][j] = norm(p[i] - p[j]);
		}
	}


	UnionFind uf(n+1);

	REP(i, n){
		REP(j, n){
			if (d[i][j] <= 100){
				uf.unite(i, j);
			}
		}
	}

	int mi = !n;
	REP(i, n){
		REP(j, n){
			if (uf.same(i, j)){
				mi = max(d[i][j], mi);
			}
		}
	}
	printf("%.10lf\n", sqrt(mi) + 2*!!n);

	return 0;
}
0