|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||128 MB||59||16||8||26.667%|
Nikola lives in Bittown and he is in love with his girlfriend Anita from a town called Hextown. Nikola knows the country map very well, and he found the shortest path between these two towns. He calls this path lucky path. The map of the country can be described as a collection of towns connected with bidirectional roads.
One day the president of this country decided that there are going to be some works on the roads. In order to uphold the traffic in the country, only one road is going to be closed per day.
For each road on the lucky path, Nikola wants to know the length of the shortest path between Anita and him if that road is closed.
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 = v1, v2, …, vk = b – the lucky path that Nikola uses.
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 (vt, vt+1) is closed. If there is no such path, output “-1” without quotes.
5 6 1 5 1 2 1 2 3 3 2 5 100 3 4 3 3 5 5 4 5 3 4 1 2 3 5
-1 101 10