#include #include #include #include #include #include #include #include #include #include #include using namespace std; long double f(long double x1, long double y1, long double x2, long double y2) { long double ret = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); return sqrt(ret); } int main() { cout << fixed << setprecision(15); int n, m; cin >> n >> m; int x, y; cin >> x >> y; x--; y--; vector a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } vector > > g(n); for (int i = 0; i < m; i++) { int p, q; cin >> p >> q; p--; q--; g[p].push_back(make_pair(f(a[p], b[p], a[q], b[q]), q)); g[q].push_back(make_pair(f(a[p], b[p], a[q], b[q]), p)); } vector d(n, -1); priority_queue, vector >, greater > > pq; pq.push(make_pair(0, x)); while (!pq.empty()) { long double cost = pq.top().first; int v = pq.top().second; pq.pop(); if (d[v] == -1) { d[v] = cost; for (auto p : g[v]) { long double cost2 = p.first; int v2 = p.second; if (d[v2] == -1) { pq.push(make_pair(cost + cost2, v2)); } } } } cout << d[y] << endl; return 0; }