#include #define REP(i, n) for(int i = 0; (i) < (n); (i)++) using namespace std; //Dijkstra struct Edge{ int to; double cost; Edge(int t, double c){ to = t; cost = c; } }; typedef pair P;//距離、点 struct Dijkstra{ int V; vector> G; vector d; double inf = 1.0e18; // 10^18 Dijkstra(int vv){ V = vv; G.resize(V); d.resize(V); } void add_data(int a, int b, double c){ Edge e1(b, c); G[a].push_back(e1); } void calc_dis(int s){ priority_queue, greater

> que; //Pのfirstが小さい奴から取り出せる REP(i, V) d[i] = inf; d[s] = 0.0; que.push(P(0, s)); while(!que.empty()){ P p = que.top(); que.pop(); int v = p.second; if(d[v] < p.first) continue; for(int i=0;i d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } }; int main() { int N, M; cin >> N >> M; int X, Y; cin >> X >> Y; int p[200005], q[200005]; REP(i, N) cin >> p[i] >> q[i]; int P[200005], Q[200005]; REP(i, M) cin >> P[i] >> Q[i]; Dijkstra dk(N); REP(i, M){ double dis = sqrt((double)((p[P[i]-1] - p[Q[i]-1]) * (p[P[i]-1] - p[Q[i]-1]) + (q[P[i]-1] - q[Q[i]-1]) * (q[P[i]-1] - q[Q[i]-1]))); //cout << dis << endl; dk.add_data(P[i]-1, Q[i]-1, dis); dk.add_data(Q[i]-1, P[i]-1, dis); } dk.calc_dis(X-1); //REP(i, N) cout << dk.d[i] << endl; cout << fixed; cout << setprecision(8) << dk.d[Y-1] << endl; return 0; }