結果

問題 No.94 圏外です。(EASY)
ユーザー tkzw_21tkzw_21
提出日時 2015-03-24 11:07:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,247 bytes
コンパイル時間 1,337 ms
コンパイル使用メモリ 149,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 14:23:19
合計ジャッジ時間 2,706 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unite(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 same(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)];
    }
};

double dist(int x1,int y1,int x2,int y2){
	return sqrt((double)(x2-x1)*(x2-x1)+(double)(y2-y1)*(y2-y1));
}

int main(void) {
	int N;
	cin >> N;
	if(N == 0){
		cout << 1 << endl;
		return 0;
	}
	vector<int> x(N),y(N);
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i];
	}
	UnionFind uf(N);
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(dist(x[i],y[i],x[j],y[j]) <= 10.){
				uf.unite(i,j);
			}
		}
	}
	
	double d = 0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(uf.same(i,j)){
				d = max(d,dist(x[i],y[i],x[j],y[j]));
			}
		}
	}	
	cout << fixed << setprecision(10) << d+2 << endl;
	return 0;
}
0