#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} struct edge{ int to, cost; }; const int INF = 1001001001; const int MAX_N = 200005; const int MAX_V = 200005; vector G[MAX_V]; int d[MAX_V]; void dijkstra(int s){ // greater

を指定することでfirstが小さい順に取り出せるようにする priority_queue, greater

> que; fill(d, d+MAX_V, INF); d[s] = 0; que.push(P(0, s)); while(!que.empty()){ P p = que.top(); que.pop(); int v = p.second; 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 ds0[MAX_N], ds1[MAX_N], dg0[MAX_N], dg1[MAX_N]; int main() { int n, m, K; cin >> n >> m >> K; int s, g; cin >> s >> g; s--, g--; rep(i,m){ int from,to,cost; cin >> from >> to; from--, to--; cost = 1; edge e1, e2; e1.to = to+100000; e1.cost = cost; e2.to = from+100000; e2.cost = cost; G[from].push_back(e1); G[to].push_back(e2); e1.to = to; e2.to = from; G[from+100000].push_back(e1); G[to+100000].push_back(e2); } dijkstra(s); rep(i,MAX_N)ds0[i] = d[i]; dijkstra(s+100000); rep(i,MAX_N)ds1[i] = d[i]; dijkstra(g); rep(i,MAX_N)dg0[i] = d[i]; dijkstra(g+100000); rep(i,MAX_N)dg1[i] = d[i]; vector ans; rep(i,n){ int x,flag = 0; x = ds0[i] + dg0[i]; if(x <= K && (K-x)%2==0)flag = 1; x = ds0[i] + dg1[i]; if(x <= K && (K-x)%2==0)flag = 1; x = ds1[i] + dg0[i]; if(x <= K && (K-x)%2==0)flag = 1; x = ds1[i] + dg1[i]; if(x <= K && (K-x)%2==0)flag = 1; if(flag)ans.push_back(i+1); } if(ans.size()==0){ cout << -1 << endl; }else{ cout << ans.size() << endl; rep(i,ans.size()){ cout << ans[i] << endl; } } return 0; }