#P1144. 最短路计数
最短路计数
Description
Given an undirected, unweighted graph with vertices and edges, where vertices are numbered . Starting from vertex , determine how many shortest paths there are to every other vertex.
Input Format
The first line contains positive integers , the number of vertices and edges of the graph.
The next lines each contain positive integers , indicating there is an edge connecting vertex and vertex . Note that self-loops and multiple edges may exist.
Output Format
Output lines. The -th line contains a non-negative integer: the number of different shortest paths from vertex to vertex . Since the answer can be large, you only need to output . If vertex is unreachable, output .
5 7
1 2
1 3
2 4
3 4
2 3
4 5
4 5
1
1
1
2
4
Hint
From to , there are shortest paths: paths and paths (because there are edges between and ).
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号