結果

問題 No.94 圏外です。(EASY)
ユーザー kurenaifkurenaif
提出日時 2016-02-18 22:15:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 2,546 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 80,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 14:43:26
合計ジャッジ時間 2,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <limits>
#include <cmath>
#include <cstdio>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

template<int N>
class union_find {
private:
	int par[N];
	int rank[N];
public:

	union_find() {
		for (int i = 0; i < N; ++i) {
			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);
	}
};

struct point {
	int x;
	int y;
	point(int x_, int y_) :x(x_), y(y_) {}
	point() :x(0), y(0) {}
};

double dist2(point left, point right) {
	return (right.x - left.x)*(right.x - left.x) + (right.y - left.y)*(right.y - left.y);
}

int main(void) {
	union_find<1001> u;
	int N;  cin >> N;
	vector<point> P;
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		P.push_back(point(x, y));
	}

	for (int a = 0; a < N; ++a) {
		for (int b = a + 1; b < N; ++b) {
			if (dist2(P[a], P[b]) <= 100) {
				u.unite(a, b);
			}
		}
	}

	int maxL = 0;
	for (int a = 0; a < N; ++a) {
		for (int b = a + 1; b < N; ++b) {
			double d = dist2(P[a], P[b]);
			if (u.same(a, b) && maxL < d)
				maxL = d;
		}
	}

	cout << fixed << setprecision(15);

	if (maxL == 0) {
		if (N > 0) cout << 2 << endl;
		else if (N == 0) cout << 1 << endl;
	}
	else cout << sqrt(maxL) + 2 << endl;

	return 0;
}
0