#include using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif template struct graph { struct edge { int to; T w; operator int() const { return to; } }; template struct edge_list { const It bg, ed; It begin() const { return bg; } It end() const { return ed; } auto&& operator[](size_t i) const { return bg[i]; } size_t size() const { return ed - bg; } }; vector> pool; vector head; vector edges; graph(int n) : head(n + 1) {} void add(int from, int to, T w = 1) { pool.push_back({from, {to, w}}); ++head[from]; } void build() { partial_sum(begin(head), end(head), begin(head)); edges.resize(head.back()); while (not empty(pool)) { edges[--head[pool.back().first]] = pool.back().second; pool.pop_back(); } decltype(pool)().swap(pool); } edge_list::const_iterator> operator[](int v) const { return {begin(edges) + head[v], begin(edges) + head[v + 1]}; } edge_list::iterator> operator[](int v) { return {begin(edges) + head[v], begin(edges) + head[v + 1]}; } size_t size() const { return std::size(head) - 1; } }; template constexpr T inf = numeric_limits::max() / 2.1; auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; }; template auto dijkstra(const G& g, int s, int t) { vector d(size(g), inf); vector prv(size(g), -1); priority_queue, vector>, greater<>> rh; rh.emplace(d[s] = 0, s); while (not empty(rh)) { auto [dv, v] = rh.top(); rh.pop(); if (dv != d[v]) continue; for (auto&& e : g[v]) if (chmin(d[e.to], dv + e.w)) { rh.emplace(d[e.to], e.to); prv[e.to] = v; } } vector vs; for (int v = t; v != -1; v = prv[v]) { vs.push_back(v); if (v == s) break; } reverse(begin(vs), end(vs)); return make_pair(d[t], vs); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n, m, k, s, t; cin >> n >> m >> k >> s >> t; --s, --t; vector x(n), y(n); for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; } graph g(n); while (m--) { int u, v; cin >> u >> v; --u, --v; double w = hypot(x[v] - x[u], y[v] - y[u]); g.add(u, v, w); g.add(v, u, w); } g.build(); set>> se; se.insert(dijkstra(g, s, t)); vector> h(n); while (k--) { if (empty(se)) { cout << "-1\n"; continue; } cout << begin(se)->first << '\n'; auto vs = begin(se)->second; se.erase(begin(se)); for (int i = 0; i < (int)size(vs) - 1; ++i) { h[vs[i]].insert(vs[i + 1]); } for (int i = 0; i < (int)size(vs) - 1; ++i) { int v = vs[i]; map mp; for (auto&& e : g[v]) { if (h[v].count(e)) { mp[e] = exchange(e.w, inf); } } if (empty(mp)) continue; auto p = dijkstra(g, s, v); auto q = dijkstra(g, v, t); if (p.first + q.first < inf) { auto nvs = p.second; nvs.insert(end(nvs), begin(q.second) + 1, end(q.second)); se.emplace(p.first + q.first, nvs); } for (auto&& e : g[v]) { if (h[v].count(e)) { e.w = mp[e]; } } } } }