OIG II - zab

// https://szkopul.edu.pl/problemset/problem/Pbxxhq_YBgWCAXYvKCfJb_HA/site/?key=statement
// OIG II (2 etap)

#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <vector>

const int sizik = 1024;

struct Point {
    int x, y;
    Point(int x, int y) : x(x), y(y) { ; }
    Point() : x(0), y(0) { ; }
};

std::array<std::vector<int>, sizik> kra;
std::bitset<sizik> vis;

std::array<Point, sizik> kam;

long long dist(const Point& a, const Point& b) {
    return ((long long)((long long)a.x - b.x) * (a.x - b.x) + (long long)(a.y - b.y) * (a.y - b.y));
}

void DFS(int v) {
    vis[v] = true;
    for (int u : kra[v]) {
        if (!vis[u]) {
            DFS(u);
        }
    }
}

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);

    int n, p, s;
    std::cin >> n >> p >> s;

    for (int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;

        kam[i] = {x, y};
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                continue;
            }

            const auto& a = kam[i];
            const auto& b = kam[j];

            long long odl = dist(a, b);

            if (odl <= (long long)s * s) {
                kra[i].push_back(j);
                kra[j].push_back(i);
            }
        }
    }

    DFS(p - 1);

    long long max_wart = 0;
    for (int i = 0; i < n; i++) {
        if (vis[i] == true) {
            const auto& a = kam[p - 1];
            const auto& b = kam[i];

            long long odl = dist(a, b);

            max_wart = std::max(max_wart, odl);
        }
    }

    std::cout << std::fixed << std::setprecision(3);

    std::cout << sqrtl(max_wart) + s << '\n';

    return 0;
}