
55  ZOJ Monthly, September 2006  1005
Given a weighted directed graph, we define the shortest path as the path who has the smallest length among all the path connecting the source vertex to the target vertex. And if two path is said to be nonoverlapping, it means that the two path has no common edge. So, given a weighted directed graph, a source vertex and a target vertex, we are interested in how many nonoverlapping shortest path could we find out at most. Input Input consists of multiple test cases. The first line of each test case, there is an integer number N (1<=N<=100), which is the number of the vertices. Then follows an N * N matrix, represents the directed graph. Each element of the matrix is either nonnegative integer, denotes the length of the edge, or 1, which means there is no edge. At the last, the test case ends with two integer numbers S and T (0<=S, T<=N1), that is, the starting and ending points. Process to the end of the file. Output For each test case, output one line, the number of the the nonoverlapping shortest path that we can find at most, or "inf" (without quote), if the starting point meets with the ending. Sample Input 4 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 0 3 5 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 0 4 Sample Output 2 1 Author: SHEN, Guanghao 