結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
tkzw_21
|
| 提出日時 | 2015-03-24 11:07:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 1,247 bytes |
| コンパイル時間 | 1,436 ms |
| コンパイル使用メモリ | 163,452 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 07:30:04 |
| 合計ジャッジ時間 | 2,244 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#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;
}
tkzw_21