100 atcoder#ABC211D. [ABC211D] Number of Shortest paths
[ABC211D] Number of Shortest paths
Score : points
Problem Statement
The Republic of AtCoder has cities numbered through and roads numbered through .
Using Road , you can travel from City to or vice versa in one hour.
How many paths are there in which you can get from City to City as early as possible? Since the count can be enormous, print it modulo .
Constraints
- The pairs are distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer. If it is impossible to get from City to City , print .
4 5
2 4
1 2
2 3
1 3
3 4
2
The shortest time needed to get from City to City is hours, which is achieved by two paths: and .
4 3
1 3
2 3
2 4
1
The shortest time needed to get from City to City is hours, which is achieved by one path: .
2 0
0
It is impossible to get from City to City , in which case you should print .
7 8
1 3
1 4
2 3
2 4
2 5
2 6
5 7
6 7
4