結果
| 問題 | 
                            No.96 圏外です。
                             | 
                    
| コンテスト | |
| ユーザー | 
                             motumotu
                         | 
                    
| 提出日時 | 2014-12-07 22:13:53 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,618 bytes | 
| コンパイル時間 | 769 ms | 
| コンパイル使用メモリ | 84,780 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-11 17:40:15 | 
| 合計ジャッジ時間 | 4,052 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 RE * 23 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-10
#define PI  (acos(-1))
#define INF 10000000
struct edge { int to; int cost; };
//===================================================
double n, x[120000], y[120000];
class UnionFind {
    int par[1000];
    int rank[1000];
public :
    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};
double twoPointDistance(int xa, int ya, int xb, int yb) {
    return sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
}
int main()
{
    UnionFind uf;
    cin >> n;
    uf.init(n);
    REP(i, n) {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            //cout << twoPointDistance(x[i], y[i], x[j], y[j]) << endl;
            if (twoPointDistance(x[i], y[i], x[j], y[j]) <= 10) {
                uf.unite(i, j);
            }
        }
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (uf.same(i, j)) {
                double t = twoPointDistance(x[i], y[i], x[j], y[j]);
                if (t > ans) {
                    ans = t;
                }
            }
        }
    }
    
    printf("%.10f\n", (n) ? ans + 2 : 1);
    return 0;
}
            
            
            
        
            
motumotu