結果

問題 No.94 圏外です。(EASY)
ユーザー imulanimulan
提出日時 2016-07-08 01:14:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,363 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 169,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 14:55:03
合計ジャッジ時間 2,481 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

struct UF{
    int n;
    //正だったらその頂点の親,負だったら根で連結成分の個数
    vector<int> d;
    UF() {}
    UF(int N):n(N), d(N,-1){}
    int root(int v){
        if(d[v]<0) return v;
        return d[v]=root(d[v]);
    }
    bool unite(int x,int y){
        x=root(x); y=root(y);
        if(x==y) return false;
        if(size(x) < size(y)) swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    int size(int v){ return -d[root(v)]; }
};

int dist(int x1, int y1, int x2, int y2)
{
    return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

int main()
{
    int n;
    cin >>n;

    if(n==0)
    {
        printf("1\n");
        return 0;
    }

    vector<int> x(n),y(n);
    rep(i,n) scanf(" %d %d", &x[i], &y[i]);

    UF t(n);
    rep(i,n)rep(j,i)
    {
        if(dist(x[i],y[i],x[j],y[j])<=10*10) t.unite(i,j);
    }

    double ans=2;
    rep(i,n)rep(j,i)
    {
        if(t.root(i)==t.root(j)) ans=max(ans,sqrt(dist(x[i],y[i],x[j],y[j]))+2);
    }

    printf("%.10lf\n", ans);
    return 0;
}
0