eolymp
bolt
Try our new interface for solving problems

Rally

The route of Antelope Gnu lies through hospitable and generous places. There is a certain chance that an important telegram arrives to any of the towns on their route, or that Panikovskiy lapses into his old ways, meaning the crew will have to spend an extra day in that town. Naturally, the time necessary to cover the same part of the route is never the same and depends on pure luck. However, the team must arrive to the glorious town of Chernomorsk as soon as possible, well, perhaps not \textbf{100}\% on time, but with a pre-defined probability of it. At the same time the chance of delays in any of the towns on their route is the same, and the delays don’t depend on each other. Let the route duration be \textbf{T}, such that the chance of covering the route in time not exceeding \textbf{T}, is not smaller than the given probability \textbf{P}. The time of covering the route includes possible delays in the first and last towns lying on the route. Help the team find the route with the smallest duration. \InputFile The first line of the input file contains two integers \textbf{N} and \textbf{M} --- the number of towns and the number of roads between them, and two real numbers \textbf{P} --- the predefined probability used to determine the route duration and \textbf{P_1} --- the probability of \textbf{24} hour delay in every town (\textbf{2} ≤ \textbf{N} ≤ \textbf{1000}, \textbf{1} ≤ \textbf{M} ≤ \textbf{10000}, \textbf{0} ≤ \textbf{P}, \textbf{P_1} ≤ \textbf{1}). \textbf{P} and \textbf{P_1} are given with five digits after the decimal point. The following \textbf{M} lines contain the descriptions of roads with three integers \textbf{A_i}, \textbf{B_i}, \textbf{L_i} each: the numbers of towns linked by a given road and time necessary to cover that distance in hours (\textbf{1} ≤ \textbf{L_i} ≤ \textbf{1000}). The roads are bidirectional. Towns are numbered from \textbf{1} through \textbf{N}. The route is set from the town with the number \textbf{1} to the town with the number \textbf{N}. No pair of towns is connected with more than one road. No road connects a town to itself. It is guaranteed that there is a path between any pair of towns and that the duration of any route doesn't change if \textbf{P} is changed by not more than \textbf{10^\{--9\}} in any direction. \OutputFile The first line of the output file must contain a single integer _ the number of towns on the optimal route. The second line must contain the numbers of these towns in the order of passing, separated by spaces.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 4 0.99000 0.50000
1 2 1
2 3 1
3 4 1
1 4 4
Output example #1
2
1 4
Source XIII All-Siberian Programming Contest named after I.V.Pottosin, November 11, 2012