結果

問題 No.94 圏外です。(EASY)
ユーザー cielciel
提出日時 2014-12-07 21:44:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 80,236 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 10:52:47
合計ジャッジ時間 1,925 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 9 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 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);
	sort(v.begin(),v.end());
	union_find uf(N);
	for(int i=0;i<N-1;i++){
		int upper=upper_bound(v.begin(),v.end(),make_pair(v[i].first+10,0))-v.begin();
		for(int j=i+1;j<upper;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