Dynamic Programming

Answer & solution
Official answer: C
Floyd–Warshall maintains shortest distances whose allowed intermediate vertices come from the first k vertices, updating dk(i, j)=min(dk−1(i, j), dk−1(i, k)+dk−1(k, j)). Reusing these subproblems is dynamic programming, C.
Define Dk(i,j) as the best i-to-j path using only vertices 1,…,k internally. Such a path either avoids k or decomposes through k into two earlier subproblems. Initialize D0 with edge weights, zero diagonals and infinity for absent edges. Iterating k,i,j uses Θ(V³) time and can reuse one distance matrix.
