結果

問題 No.96 圏外です。
ユーザー cielciel
提出日時 2014-12-07 23:10:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 83,340 KB
実行使用メモリ 13,892 KB
最終ジャッジ日時 2023-09-02 11:06:14
合計ジャッジ時間 8,614 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,540 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 13 ms
4,612 KB
testcase_10 AC 17 ms
4,664 KB
testcase_11 WA -
testcase_12 AC 26 ms
7,300 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 72 ms
13,892 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 63 ms
5,684 KB
testcase_21 AC 48 ms
4,476 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <unordered_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 X(a,b,t) (((a).t-(b).t)*((a).t-(b).t))
#define Z(a,b) (X(a,b,first) + X(a,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,9999999))-v.begin();
		for(int j=i+1;j<upper;j++){
			if(Z(v[i],v[j])<=100)uf.unite(i,j);
		}
	}
	int result=0;
	unordered_map<int,vector<int> >z;
	for(int i=0;i<N;i++){
		int r=uf.root(i);
		z[r].push_back(i);
	}
	for(auto &it:z){
		for(int i=0;i<it.second.size()-1;i++){
			for(int j=it.second.size()-1;j>i;j--){
				if(X(v[it.second[i]],v[it.second[j]],first)<result)break;
				result=max(result,Z(v[it.second[i]],v[it.second[j]]));
			}
		}
	}
	printf("%.9f\n",sqrt(result)+2);
}
0