All Tracks Algorithms Graphs Breadth First Search Problem

The Flight Plan
/

Algorithms, Breadth-first search, Graph

Problem
Editorial
Analytics

You are given flights route map of a country consisting of N cities and M undirected flight routes. Each city has an airport and each airport can work as layover. The airport will be in two states, Loading and Running. In loading state, luggage is loaded into the planes. In the running state, planes will leave the airport for the next city. All the airports will switch their states from Loading to Running and vice versa after every T minutes. You can cross a city if its airport state is running. Initially, all the airports are in running state. At an airport, if its state is loading, you have to wait for it to switch its state to running. The time taken to travel through any flight route is C minutes. Find the lexicographically smallest path which will take the minimum amount of time (in minutes) required to move from city X to city Y.

It is guaranteed that the given flight route map will be connected. Graph won't contain multiple edges and self loops. A self loop is an edge that connects a vertex to itself.

Input Format:
The first line contains 4 space separated integers, N, M, T and C. Next M lines contains two space separated integers each, U and V denoting that there is a bidirectional road between city U and city V. Next line contains two space separated integers, X and Y.

Output Format:
In the first line print an integer K, denoting the number of city you need to go through to reach city Y from the city X. In next line, print K space separated integers denoting the path which will take the minimum amount of time (in minutes) required by to move from city X to city Y. There can be multiple paths. Print the lexicographically smallest one.

Constraints:
\(1 \le N \le 10^3\)
\(N-1 \le M \le \frac {N*(N-1)} 2\)
\(1 \le C \le 10^3\)
\(1 \le T \le 10^3\)
\(1 \le U, V, X, Y \le N\)

SAMPLE INPUT
5 5 3 5
1 2
1 3
2 4
1 4
2 5
1 5
SAMPLE OUTPUT
3
1 2 5 
Explanation

Fastest path will be \(1 -> 2 -> 5\). You can reach city 2 in 5 minutes. After 3 minutes the airport in city 2 will change its state to Loading. So in city 2, you have to wait for 1 minute for the airport to change its state. So total time will be 5 minutes (from city 1 to city 2) + 1 minute (waiting time at city 2) + 5 minutes (from city 2 to city 5) = \(11\) minutes.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?