#include #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) using namespace std; using ll = double; constexpr char newl = '\n'; struct State { int at; ll cost; bitset<2000> vis; State(int at, ll cost) : at(at), cost(cost) {} bool operator>(const State& s) const { return cost > s.cost; } }; struct Edge { int to; ll cost; Edge(int to, ll cost) : to(to), cost(cost) {} }; using Graph = vector< vector >; //隣接リスト const ll INF = 1e15; //const int NONE = -1; //sは始点、mincは最短経路のコスト、prevsは最短経路をたどる際の前の頂点 void dijkstra(int s, int t, const Graph& graph, int K){ const int n = graph.size(); vector< vector > minc(n); priority_queue, greater > pq; { State hoge(s, 0); hoge.vis.set(s); pq.push(move(hoge)); } while(!pq.empty()) { State cur = pq.top(); pq.pop(); if (minc[cur.at].size() >= K) continue; minc[cur.at].push_back(cur.cost); for(const Edge& e : graph[cur.at]) { if (cur.vis[e.to] || minc[e.to].size() >= K) continue; ll cost = cur.cost + e.cost; State nex(cur); nex.vis.set(e.to); nex.at = e.to; nex.cost = cost; pq.push(move(nex)); } } for (int i = 0; i < K; i++) { cout << fixed << setprecision(15) << (i >= minc[t].size() ? -1 : minc[t][i]) << newl; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m, K; cin >> n >> m >> K; int x, y; cin >> x >> y; --x; --y; vector p(n), q(n); for (int i = 0; i < n; i++) { cin >> p[i] >> q[i]; } Graph g(n); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; --u; --v; ll cost = hypot(p[u] - p[v], q[u] - q[v]); g[u].emplace_back(v, cost); g[v].emplace_back(u, cost); } dijkstra(x, y, g, K); return 0; }