#P11966. Shortest Time to School
Shortest Time to School
Shortest Time to School
In city C, there is an undirected graph with nodes and edges. The nodes are numbered , and for each edge (), it connects node and node with a length of meters. The school is located at node . There are students. For the -th student, his/her home is at node , and he/she walks at a speed of 1 meter per second. Your task is to compute the minimum number of seconds required for each student to reach the school, assuming they take the shortest possible path.
inputFormat
The first line contains three integers , , and ().
Each of the next lines contains three integers , , and , describing an undirected edge between nodes and with length meters (, ).
The next line contains an integer , the number of queries (i.e., the number of students).
Each of the next lines contains one integer , representing the home node of the -th student.
outputFormat
Output lines. The -th line should contain one integer: the minimum number of seconds required for the -th student to reach school (i.e., the shortest distance in meters from node to node ).
sample
4 4 1
1 2 5
2 3 5
3 4 5
1 4 20
3
1
2
4
0
5
15
</p>