#P1811. 最短路
最短路
Description
Given an undirected graph with vertices and edges, where each edge has weight .
You are also given ordered triples , meaning that after moving from to , you are not allowed to move to . Note that the triples are ordered; for example, it is allowed to go from to and then to .
Under the constraints given by the triples, find the shortest path from node to node , and output any valid path. A Check will verify your output.
Input Format
The first line contains three integers , , , as described above.
Each of the next lines contains two integers , , indicating there is an edge between and .
Each of the next lines contains three integers describing one triple.
Output Format
Output consists of two lines. The first line contains a single integer , the length of the shortest path.
The second line contains integers, the sequence of nodes visited from to .
4 4 2
1 2
2 3
3 4
1 3
1 2 3
1 3 4
4
1 3 2 3 4
Hint
For 40% of the testdata, , , .
For 100% of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号