#include using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif template struct graph { struct edge { int to; T w; operator int() const { return to; } }; template struct edge_list { const It bg, ed; It begin() const { return bg; } It end() const { return ed; } auto&& operator[](size_t i) const { return bg[i]; } size_t size() const { return ed - bg; } }; vector> pool; vector head; vector edges; graph(int n) : head(n + 1) {} void add(int from, int to, T w = 1) { pool.push_back({from, {to, w}}); ++head[from]; } void build() { partial_sum(begin(head), end(head), begin(head)); edges.resize(head.back()); while (not empty(pool)) { edges[--head[pool.back().first]] = pool.back().second; pool.pop_back(); } decltype(pool)().swap(pool); } edge_list::const_iterator> operator[](int v) const { return {begin(edges) + head[v], begin(edges) + head[v + 1]}; } edge_list::iterator> operator[](int v) { return {begin(edges) + head[v], begin(edges) + head[v + 1]}; } size_t size() const { return std::size(head) - 1; } }; template constexpr T inf = numeric_limits::max() / 2.1; auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; }; template auto dijkstra(const G& g, int s) { vector d(size(g), inf); vector prv(size(g), -1); priority_queue, vector>, greater<>> rh; rh.emplace(d[s] = 0, s); while (not empty(rh)) { auto [dv, v] = rh.top(); rh.pop(); if (dv != d[v]) continue; for (auto&& e : g[v]) if (chmin(d[e.to], dv + e.w)) { rh.emplace(d[e.to], e.to); prv[e.to] = v; } } return make_pair(d, prv); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n, m, s, t; cin >> n >> m >> s >> t; --s, --t; vector x(n), y(n); for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; } graph g(n); while (m--) { int u, v; cin >> u >> v; --u, --v; double w = hypot(x[v] - x[u], y[v] - y[u]); g.add(u, v, w); g.add(v, u, w); } g.build(); cout << dijkstra(g, s).first[t] << '\n'; }