#include #include #include #include #include #include #include #include template inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } // [l, r) from l to r struct range { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; // [l, r) from r to l struct revrange { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; int main() { int N, M; std::cin >> N >> M; int S, G; std::cin >> S >> G; --S; --G; std::vector X(N), Y(N); for (int i: range(0, N)) { std::cin >> X[i] >> Y[i]; } std::vector>> graph(N); for (int i: range(0, M)) { int x, y; std::cin >> x >> y; --x; --y; double d = std::hypot(X[x] - X[y], Y[x] - Y[y]); graph[x].emplace_back(y, d); graph[y].emplace_back(x, d); } std::vector dist(N, 1e9); using state = std::pair; std::priority_queue, std::greater> que; dist[S] = 0; que.emplace(dist[S], S); while (!que.empty()) { auto [d, u] = que.top(); que.pop(); if (d > dist[u]) { continue; } for (auto e: graph[u]) { if (chmin(dist[e.first], dist[u] + e.second)) { que.emplace(dist[e.first], e.first); } } } std::cout << std::fixed << std::setprecision(20); std::cout << dist[G] << '\n'; return 0; }