結果

問題 No.94 圏外です。(EASY)
ユーザー nodchipnodchip
提出日時 2014-12-07 19:40:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 2,651 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 106,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 14:11:56
合計ジャッジ時間 2,099 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
typedef long long ll;
typedef unsigned long long ull;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

typedef complex<double> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(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 findSet(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 main() {
	std::ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<P> pos;
	REP(n, N) {
		int x, y;
		cin >> x >> y;
		pos.push_back(P(x, y));
	}

	UnionFind uf(N);
	REP(i, N) {
		REP(j, i) {
			if (abs(pos[i] - pos[j]) < 10 + EPS) {
				uf.unionSet(i, j);
			}
		}
	}

	double answer = 1.0;
	if (N) {
		answer = 2.0;
	}
	REP(i, N) {
		REP(j, i) {
			if (!uf.findSet(i, j)) {
				continue;
			}
			MAX_UPDATE(answer, abs(pos[i] - pos[j]) + 2.0);
		}
	}

	printf("%.20f\n", answer);
}
0