Floyd - existence
The directed weighted graph is given. Using its weighted matrix, determine for each pair of vertices whether there exists a shortest path between them or not.
The shortest path may not exist for two reasons:
There is no way.
There is a way of arbitrarily small weight.
Input
The first line contains the number of vertices . The next lines contains numbers that describe the weighted matrix (-th of the -th row corresponds to the weight of the edge from vertex to vertex ). The number in this matrix represents no edge, and any other number — the existence of an edge of corresponding weight. All the numbers do not exceed by absolute value.
Output
Print rows with numbers: the -th number in the -th row must be if the path from to does not exist, if there is a shortest path, and if there is a path of arbitrarily small weight.