// 以下のライブラリを使ってみる. // 素集合データ構造(Union-Find) // https://ei1333.github.io/luzhiled/snippets/structure/union-find.html #include using namespace std; using LL = long long; struct UnionFind{ vector data; UnionFind(LL sz){ data.assign(sz, -1); } // 頂点 x, y の 結合. bool unite(LL x, LL y){ x = find(x), y = find(y); if(x == y) return false; if(data[x] > data[y]) swap(x, y); data[x] += data[y]; data[y] = x; return true; } // 頂点 k を 探索. LL find(LL k){ if(data[k] < 0) return k; return data[k] = find(data[k]); } // 頂点 k を含む集合 の 大きさ. LL size(LL k){ return (-data[find(k)]); } }; // 辺 // f: 始点 // t: 終点 // c: 距離. struct edge{ int f, t; LL c; bool operator < (const edge& rhs) const{ if (c > rhs.c) return true; else return false; } }; int main(){ // 1. 入力情報取得. int N; scanf("%d", &N); LL x[N], y[N]; for(int i = 0; i < N; i++) scanf("%llu %llu", x + i, y + i); // 2. Union-Find木. priority_queue pq; UnionFind uf(N); // 3. 各2点間の距離を計算. // 下記, 解説サイト参照. // https://kenkoooo.hatenablog.com/entry/2015/03/20/011546 for(int i = 0; i < N; i++){ for(int j = 0; j < i; j++){ LL dx = x[i] - x[j], dy = y[i] - y[j]; LL d2 = dx * dx + dy * dy; LL d = sqrt(d2); while(d2 > d * d) d++; d = (d + 9LL) / 10LL * 10LL; edge e; e.f = i, e.t = j, e.c = d; pq.push(e); // cout << "i=" << i << " j=" << j << " d=" << d << " d2=" << d2 << endl; } } // 4. A君が買う必要のある最も短いものさしは? LL ans = 0LL; while(uf.find(0) != uf.find(N - 1)){ edge e = pq.top(); pq.pop(); // cout << "e.f=" << e.f << " e.t=" << e.t << " e.c=" << e.c << endl; if(uf.find(e.f) != uf.find(e.t)){ uf.unite(e.f, e.t); ans = max(ans, e.c); } } // 5. 後処理. printf("%llu\n", ans); return 0; }