結果

問題 No.94 圏外です。(EASY)
ユーザー cielciel
提出日時 2014-12-07 21:11:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,100 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 76,872 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 14:14:53
合計ジャッジ時間 1,899 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

class union_find{
	int *parent,n;
public:
	int root(int a){return parent[a]==a?a:(parent[a]=root(parent[a]));}
	union_find(int _n){
		n=_n;
		parent=new int[n];
		for(int i=0;i<n;i++)parent[i]=i;
	}
	~union_find(){delete []parent;}
	int unite(int a,int b){
		int x=root(a),y=root(b);if(x==y)return 0;
		parent[y]=x;
		return 1;
	}
};

#define Z(a,b) ((a).first-(b).first)*((a).first-(b).first) + ((a).second-(b).second)*((a).second-(b).second)
int main(){
	int N;
	scanf("%d",&N);
	if(N==0){
		puts("1");
		return 0;
	}
	vector<pair<int,int> >v(N);
	for(int i=0;i<N;i++)scanf("%d%d",&v[i].first,&v[i].second);
	union_find uf(N);
	for(int i=0;i<N-1;i++)for(int j=i+1;j<N;j++){
		if(Z(v[i],v[j])<=100)uf.unite(i,j);
	}
	int result=0;
	map<int,vector<int> >z;
	for(int i=0;i<N;i++){
		int r=uf.root(i);
		z[r].push_back(i);
		for(int j=0;j<z[r].size()-1;j++){
			result=max(result,Z(v[z[r][j]],v[i]));
		}
	}
	printf("%.9f\n",sqrt(result)+2);
}
0