Write a program that, given a directed graph with positive costs at the arcs, and two vertices and , prints the path of minimum cost that goes from to .
Input consists of several cases. Every case begins with the number of vertices and the number of arcs . Follow triples , indicating that there is an arc of cost , where and . Finally, we have and . Assume , , and that for every pair of vertices and there is at most one arc of the kind . All numbers are integers. Vertices are numbered from 0 to . If is reachable from , you have the guarantee that there is a unique path.
The condition for was previously . It was updated to create new test cases.
For every case, print the path of minimum cost that goes from to . If there is no path from to , state so.
Author: Salvador Roura
Generation: 2026-01-25T10:08:16.197Z
© Jutge.org, 2006–2026.
https://jutge.org