| acmsguru |
|---|
| Finished |
It slows you down by the time equal to the time you spent running through the route. So it's like if you ran through the route 2 times. Also, if your path contains several such routes as subpaths, then each of them counts. For example, there can be two exactly equal routes in the input, and if your path contains such route, then it's actually as if you ran 3 times through the route. Find the shortest time to get from one node to another in such a strange graph with "bonuses".
,
,
, 1 ≤ S, T ≤ n, S ≠ T. The nodes in the graph are numbered from 1 to n. Each of the following m lines contains three integers a, b, c, (
), where a and b are nodes and c is the time to run through the edge (a, b). The graph is directed: you can't run from b to a along the edge (a, b). There are no more than 10 edges going out from each node. Each of the next r lines contains a description of a special route. It begins with integer k — the number of edges in the route. Then k integers follow — the numbers of the edges in the route. Edges are numbered from 1 to m in the same order that they are written above. Sum of lengths of all routes is not more than 2m. Each edge occurs no more than in 10 special routes. Each special route is correct: no vertex can appear twice in any given route, and the end of each edge of the route except the last one coincides with the start of the next edge. sample input | sample output |
3 3 1 1 3 1 2 2 2 3 1 1 3 2 1 3 | 3 2 1 2 |
sample input | sample output |
3 3 3 1 3 1 2 2 2 3 2 1 3 1 1 3 1 3 1 3 | 4 2 1 2 |
sample input | sample output |
4 3 3 1 4 1 2 3 2 3 2 3 4 1 3 1 2 3 2 2 3 1 3 | 16 3 1 2 3 |
| Name |
|---|


