#pragma GCC optimize ("O2") #pragma GCC target ("avx2") #include using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define Would #define you #define please int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M, P; cin >> N >> M >> P; int S, G; cin >> S >> G; #define PT pair vector E[200001]; rep(i, M) { int u, v; cin >> u >> v; E[u * 2].pb({ 1, v * 2 + 1 }); E[u * 2 + 1].pb({ 1, v * 2 }); E[v * 2].pb({ 1, u * 2 + 1 }); E[v * 2 + 1].pb({ 1, u * 2 }); } ll DS[200001], DG[200001]; rep1(i, N * 2) DS[i + 1] = 1e18; rep1(i, N * 2) DG[i + 1] = 1e18; priority_queue, greater> que; DS[S * 2] = 0; que.push(mp(0, S * 2)); while (que.size()) { PT p = que.top(); que.pop(); int i = p.second; if (DS[i] != p.first) continue; for (PT p2 : E[i]) { int j = p2.second; ll d = DS[i] + p2.first; if (DS[j] > d) { DS[j] = d; que.push(mp(d, j)); } } } DG[G * 2] = 0; que.push(mp(0, G * 2)); while (que.size()) { PT p = que.top(); que.pop(); int i = p.second; if (DG[i] != p.first) continue; for (PT p2 : E[i]) { int j = p2.second; ll d = DG[i] + p2.first; if (DG[j] > d) { DG[j] = d; que.push(mp(d, j)); } } } vector kotae; rep1(i, N) { if (P % 2) { ll tmp = min(DS[i * 2] + DG[i * 2 + 1], DS[i * 2 + 1] + DG[i * 2]); if (tmp <= P) { kotae.pb(i); } } else { ll tmp = min(DS[i * 2] + DG[i * 2], DS[i * 2 + 1] + DG[i * 2 + 1]); if (tmp <= P) { kotae.pb(i); } } } int kazu = kotae.size(); if (kazu == 0) co(-1); else { co(kotae.size()); rep(i, kotae.size()) co(kotae[i]); } Would you please return 0; }