#P1608. Counting Shortest Paths in a Directed Graph
Counting Shortest Paths in a Directed Graph
Counting Shortest Paths in a Directed Graph
In this problem, you are given a directed graph representing towns and roads. The graph consists of nodes (towns) and directed edges. Town is the starting point and town is the destination. Each edge from town to town requires time. Your task is to find the number of distinct shortest paths from town to town . Two paths are considered different if the sequence of towns is different. If there is no path from town to town , output .
inputFormat
The first line contains two integers and , representing the number of towns and the number of directed roads, respectively. Each of the following lines contains three integers , , and , representing a one-way road from town to town with a travel time of .
outputFormat
Output a single integer representing the number of distinct shortest paths from town to town .
sample
4 5
1 2 1
1 3 1
2 4 1
3 4 1
2 3 1
2