Greg and Graph
MediumRating 1700CodeforcesShortest Paths & Topological Sort
Approach hintTry it first, then revealHide
Reverse time: add the vertices back in the opposite order of deletion and use each one as the next intermediate vertex of Floyd-Warshall. After each addition, sum the distances among the vertices added so far. O(n^3).