#Q79. 「一本通 3.2 练习 3」最短路计数
「一本通 3.2 练习 3」最短路计数
Description
Given an undirected and unweighted graph with vertices and edges, where the vertices are labeled from to . Determine the number of shortest paths from vertex to each of the other vertices.
Input Format
The first line contains two positive integers and , representing the number of vertices and edges in the graph, respectively.
The next lines each contain two positive integers and , indicating an edge between vertex and vertex . Note that there may be self-loops and multiple edges.
Output Format
Output lines, each containing a non-negative integer. The -th line should output the number of different shortest paths from vertex to vertex , modulo . If vertex is unreachable from vertex , output .
Sample 1
There are shortest paths from to : paths via and paths via (since there are edges between and ).
5 7
1 2
1 3
2 4
3 4
2 3
4 5
4 5
1
1
1
2
4
Data Range and Hints
For of the data, ;
For of the data, ;
For of the data, .