#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; using CostType = double; struct Edge { int src, dst; CostType cost; Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {} inline bool operator<(const Edge &x) const { return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src; } inline bool operator<=(const Edge &x) const { return !(x < *this); } inline bool operator>(const Edge &x) const { return x < *this; } inline bool operator>=(const Edge &x) const { return !(*this < x); } }; struct Dijkstra { using Pci = pair; Dijkstra(const vector> &graph, const CostType CINF) : graph(graph), CINF(CINF) {} vector build(int s) { int n = graph.size(); vector dist(n, CINF); dist[s] = 0; prev.assign(n, -1); priority_queue, greater> que; que.emplace(0, s); while (!que.empty()) { CostType cost; int ver; tie(cost, ver) = que.top(); que.pop(); if (dist[ver] < cost) continue; for (const Edge &e : graph[ver]) { if (dist[e.dst] > dist[ver] + e.cost) { dist[e.dst] = dist[ver] + e.cost; prev[e.dst] = ver; que.emplace(dist[e.dst], e.dst); } } } return dist; } vector build_path(int t) { vector res; for (; t != -1; t = prev[t]) res.emplace_back(t); reverse(ALL(res)); return res; } private: vector> graph; const CostType CINF; vector prev; }; int main() { int n, m, x, y; cin >> n >> m >> x >> y; --x; --y; vector p(n), q(n); REP(i, n) cin >> p[i] >> q[i]; vector> graph(n); while (m--) { int P, Q; cin >> P >> Q; --P; --Q; double dist = sqrt((p[P] - p[Q]) * (p[P] - p[Q]) + (q[P] - q[Q]) * (q[P] - q[Q])); graph[P].emplace_back(P, Q, dist); graph[Q].emplace_back(Q, P, dist); } Dijkstra dij(graph, LINF); cout << dij.build(x)[y] << '\n'; return 0; }