結果

問題 No.94 圏外です。(EASY)
ユーザー yaoshimax
提出日時 2015-03-05 01:30:50
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 2,510 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 88,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 07:29:09
合計ジャッジ時間 1,749 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
class UnionFindTree
{
private:
int N;
int *rootnum;
int *rank;
int *unionnum;
public:
UnionFindTree(int n){
/*0n-1union*/
N = n;
rootnum = new int[N];
rank = new int[N];
unionnum = new int[N];
for( int i = 0 ; i < N ; i++ ){
rootnum[i] = i;
rank[i] = 0;
unionnum[i] = 1;
}
}
int Find( int j ){
if( rootnum[j] == j ){
return j;
}
else{
return rootnum[j] = Find(rootnum[j]);
}
}
void Union( int i , int j ){
int x = Find(i);
int y = Find(j);
if( x == y ) return;
N--;
if( rank[x] < rank[y] ){
rootnum[y] = x;
unionnum[x] += unionnum[y];
}else{
rootnum[x] = y;
unionnum[y] += unionnum[x];
if( rank[x]==rank[y] ) rank[x]++;
}
}
int Num( int j ){
/**/
int x = Find(j);
return unionnum[x];
}
int UnionNum(){
/**/
return N;
}
~UnionFindTree(){
delete rootnum;
delete rank;
delete unionnum;
}
};
int main(){
int N;
cin >> N;
int X[N];
int Y[N];
UnionFindTree uft(N);
for( int i = 0 ; i < N ; i++ ) cin >> X[i] >> Y[i];
for( int i = 0 ; i < N ; i++ ){
for( int j = i+1 ; j < N ; j++ ){
int dX=X[i]-X[j];
int dY=Y[i]-Y[j];
if( dX*dX+dY*dY <= 100 ){
uft.Union(i,j);
}
}
}
int maxDist = 0;
for( int i = 0 ; i < N ; i++ ){
for( int j = 0 ; j < N ; j++ ){
int dX=X[i]-X[j];
int dY=Y[i]-Y[j];
if( uft.Find(i)==uft.Find(j) ){
maxDist = max(maxDist,dX*dX+dY*dY);
}
}
}
if( N == 0 ){
printf("%.10f\n",1.0);
}
else{
printf("%.10f\n",2.0+sqrt((double)maxDist));
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0