結果

問題 No.94 圏外です。(EASY)
ユーザー cormorancormoran
提出日時 2016-02-18 23:06:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,792 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 14:43:50
合計ジャッジ時間 1,590 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

template<typename T>
ostream& operator << (ostream &os , const vector<T> &v){
    rep(i,v.size()) os << v[i] << (i!=v.size()-1 ? " " : "\n"); return os;
}

template<typename T>
istream& operator >> (istream &is , vector<T> &v){
    rep(i,v.size()) is >> v[i]; return is;
}

//Node 0 to n-1でも1 to nでもOK
struct UnionFind{
    int n;
    vector<int> p;
    UnionFind(int nn):n(nn+1){
        p.resize(n);
        rep(i,n) p[i] = i;
    }
    int root(int x){
    if(p[x] == x) return x;
    else return p[x] = root(p[x]);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x != y) p[y] = x;
    }
    bool query(int x,int y){
        return root(x) == root(y);
    }
};

double d2(pii a,pii b){
    return pow(a.first - b.first,2) + pow(a.second - b.second, 2);
}
bool solve(){
    int N; cin >> N;
    if(N == 0){
        cout << 1 << endl;
        return false;
    }
    vector<pii> X(N);
    rep(i,N) cin >> X[i].first >> X[i].second;
    UnionFind ut(N);
    rep(i,N){
        rep(j,N){
            if(i != j){
                if(d2(X[i], X[j]) <= 10*10) ut.unite(i,j);
            }
        }
    }
    double mx2 = 0;
    rep(i, N){
        rep(j, N){
            if(ut.query(i, j)){
                mx2 = max(mx2, d2(X[i], X[j]));
            }
        }
    }
    printf("%.8f\n",sqrt(mx2) + 2.0);
    
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}
0