Given a directed and complete graph with vertices, compute the maximum cost of all the paths with the vertices in increasing order. The given graph is represented by an matrix , where for every pair with , is the (perhaps negative) cost of the arc from to .
For instance, the maximum cost of the first test is 100, because of the path , with cost .
Input consists of the number of vertices , followed by the matrix ( lines, each one with integer numbers), followed by the initial vertex . Vertices are numbered from 0 to . You can assume , that the diagonal has only zeros, and that the rest of numbers are between and .
Print the maximum cost of all the paths with the vertices in increasing order.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T11:33:45.565Z
© Jutge.org, 2006–2026.
https://jutge.org