SP22037 SPATHS - Shortest Paths
Description
Nikola lives in Bittown and he is in love with his girlfriend Anita from a town called Hextown. Nikola
Input Format
The first line of input contains four integers : n - the number of cities, m - the number of roads
between these towns, a - index of town Bittown where Nikola lives, b - the index of town
Hextown where Anita lives. Towns are indexed with numbers 1, 2,…, n. Next m lines specify roads :
each line contains three integers : u, v and w - there exist road between towns u and v with length w.
Last line of the input contains number k followed by k numbers a = v $ _{1} $ , v $ _{2} $ , …, v $ _{k} $ = b - the lucky path
that Nikola uses.
Output Format
For every integer t = 1 … k - 1, in separate line, print the length of the shortest path between cities a
and b, if the road (v $ _{t} $ , v $ _{t + 1} $ ) is closed. If there is no such path, output “-1” without quotes.