結果
| 問題 |
No.94 圏外です。(EASY)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-07 20:44:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,413 bytes |
| コンパイル時間 | 832 ms |
| コンパイル使用メモリ | 99,580 KB |
| 実行使用メモリ | 7,680 KB |
| 最終ジャッジ日時 | 2024-06-11 17:05:19 |
| 合計ジャッジ時間 | 1,734 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 2 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
// Union-Find木
class UnionFindTree
{
int n;
vector<int> parent; // 親ノード
vector<int> rank; // 木の高さの上限
vector<int> num; // グループの要素数
int find(int x){
if(parent[x] == x)
return x;
return parent[x] = find(parent[x]);
}
public:
UnionFindTree(int n0){ // コンストラクタ
n = n0;
parent.resize(n);
for(int i=0; i<n; ++i)
parent[i] = i;
rank.assign(n, 0);
num.assign(n, 1);
}
void unite(int x, int y){ // xとyのグループを併合
if((x = find(x)) != (y = find(y))){
if(rank[x] < rank[y]){
parent[x] = y;
num[y] += num[x];
}else{
parent[y] = x;
if(rank[x] == rank[y])
++ rank[x];
num[x] += num[y];
}
-- n;
}
}
bool same(int x, int y){ // xとyのグループが同じかを調べる
return find(x) == find(y);
}
int getNum(){ // グループの数を返す
return n;
}
int getNum(int x){ // xのグループの要素数を返す
return num[find(x)];
}
};
int main()
{
int n;
cin >> n;
vector<int> x(n), y(n);
for(int i=0; i<n; ++i)
cin >> x[i] >> y[i];
vector<vector<int> > dist(n, vector<int>(n));
UnionFindTree uft(n);
for(int i=0; i<n; ++i){
for(int j=i+1; j<n; ++j){
int dy = y[i] - y[j];
int dx = x[i] - x[j];
dist[i][j] = dy * dy + dx * dx;
if(dist[i][j] <= 100)
uft.unite(i, j);
}
}
double ret = 1.0;
for(int i=0; i<n; ++i){
for(int j=i+1; j<n; ++j){
if(uft.same(i, j))
ret = max(ret, sqrt((double)dist[i][j]) + 2.0);
}
}
printf("%.10f\n", ret);
return 0;
}