#include #define FASTIO using namespace std; using ll = long long; using Vi = vector; using Vl = vector; using Pii = pair; using Pll = pair; constexpr int I_INF = numeric_limits::max(); constexpr ll L_INF = numeric_limits::max(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% struct Pos { double x, y; }; double distance(const Pos& a, const Pos& b) { double dx = a.x - b.x; double dy = a.y - b.y; return sqrt(dx * dx + dy * dy); } constexpr double D_INF = 1e20; using Pid = pair; using Pdi = pair; using Graph = vector>; void solve() { ll N, M, X, Y; cin >> N >> M >> X >> Y; --X, --Y; vector poss(N); for (ll i = 0; i < N; i++) { cin >> poss[i].x >> poss[i].y; } Graph g(N); for (ll i = 0; i < M; i++) { ll a, b; cin >> a >> b; --a, --b; double c = distance(poss[a], poss[b]); g[a].emplace_back(b, c); g[b].emplace_back(a, c); } vector dist(N, D_INF); dist[X] = 0.0; priority_queue, greater> q; q.emplace(0.0, X); while (!q.empty()) { auto [cost, idx] = q.top(); q.pop(); if (dist[idx] < cost) continue; for (const auto& [to, c] : g[idx]) { double ncost = cost + c; if (ncost >= dist[to]) continue; dist[to] = ncost; q.emplace(ncost, to); } } cout << setprecision(20) << dist[Y] << "\n"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int main() { #ifdef FASTIO cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); #endif #ifdef FILEINPUT ifstream ifs("./in_out/input.txt"); cin.rdbuf(ifs.rdbuf()); #endif #ifdef FILEOUTPUT ofstream ofs("./in_out/output.txt"); cout.rdbuf(ofs.rdbuf()); #endif solve(); cout << flush; return 0; }