#Q227. 「一本通 6.5 练习 3」迷路
「一本通 6.5 练习 3」迷路
Description
Original source: SCOI 2009
Windy is lost in a directed graph. The graph has nodes, and Windy starts at node . He must arrive exactly at time at node .
Given the directed graph, can you tell Windy how many different paths there are?
Note: Windy cannot linger at any node, and the time taken to traverse each directed edge is exactly the given time.
Input Format
The first line contains two integers, ;
The next lines each contain a string of length . The -th character in the -th line is 0 if there is no edge from node to node $j`, or a digit from `1` to `9` representing the time required to traverse the edge from node $ij`.
Output Format
Output a single integer, the number of possible paths. This number may be very large, so only output the remainder when divided by .
Sample 1
2 2
11
00
1
Sample 2
5 30
12045
07105
47805
12024
12345
852
Data Range and Hints
For of the data, ;
For of the data, .