#include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; struct Graph { static constexpr double INF = 1e+100; struct VertexQ { bool operator<(const VertexQ &o) const { return c > o.c; // 逆 } int i; double c; }; struct Vertex { int n; double c; }; struct Edge { int i, n; double c; }; Graph(int n, int m) : v(n, { -1, INF }), e(m), n(n), m(0) {} void add_edge(int i, int j, double c) { e[m] = { j, v[i].n, c }; v[i].n = m; m++; } void dijkstra(int i, int j) { for (int i = 0; i < n; i++) v[i].c = INF; priority_queue q; q.push({ i, v[i].c = 0 }); while (!q.empty()) { auto p = q.top(); q.pop(); if (p.i == j) break; if (p.c > v[p.i].c) continue; for (int j = v[p.i].n; j >= 0; j = e[j].n) { Edge &o = e[j]; double c = p.c + o.c; if (c < v[o.i].c) q.push({ o.i, v[o.i].c = c }); } } } vector v; vector e; int n, m; }; int main() { int n, m; cin >> n >> m; Graph g(n, m * 2); int x, y; cin >> x >> y; x--; y--; vector> p(n); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; p[i] = { x, y }; } for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; double c = hypot(p[a].first - p[b].first, p[a].second - p[b].second); g.add_edge(a, b, c); g.add_edge(b, a, c); } g.dijkstra(x, y); cout << fixed << setprecision(9) << g.v[y].c << '\n'; return 0; }