- #include < iostream > #include < cmath > #include < cstdio > #include < cstring > #include < algorithm > #define MAXN 1000001 using namespace std;
- struct nond {
- int x,
- y;
- double z;
- }
- edge[MAXN];
- double num[MAXN];
- int n,
- k,
- tot,
- tot1,
- x[MAXN],
- y[MAXN],
- fa[MAXN];
- int cmp(nond a, nond b) {
- return a.z < b.z;
- }
- int cmp1(double x, double y) {
- return x > y;
- }
- int find(int x) {
- if (fa[x] == x) return x;
- else return fa[x] = find(fa[x]);
- }
- int main() {
- //freopen("people.in","r",stdin);
- //freopen("people.out","w",stdout);
- scanf("%d%d", &n, &k);
- for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
- for (int i = 1; i <= n; i++) fa[i] = i;
- for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) {
- edge[++tot].x = i;
- edge[tot].y = j;
- edge[tot].z = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
- }
- sort(edge + 1, edge + 1 + tot, cmp);
- for (int i = 1; i <= tot; i++) {
- int dx = find(edge[i].x);
- int dy = find(edge[i].y);
- if (dx == dy) continue;
- fa[dx] = dy;
- num[++tot1] = edge[i].z;
- if (tot1 == tot - 1) break;
- }
- sort(num + 1, num + 1 + tot1, cmp1);
- printf("%.2lf", num[k - 1]);
- }