結果

問題 No.94 圏外です。(EASY)
ユーザー mamekin
提出日時 2014-12-07 20:46:25
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 2,413 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 98,680 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2024-06-26 07:20:52
合計ジャッジ時間 1,821 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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){ // xy
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){ // xy調
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; 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] <= 10 * 10)
uft.unite(i, j);
}
}
double ret = 1.0;
for(int i=0; i<n; ++i){
for(int j=i; j<n; ++j){
if(uft.same(i, j))
ret = max(ret, sqrt((double)dist[i][j]) + 2.0);
}
}
printf("%.10f\n", ret);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0