Graph Theory37 sections · 1633 units
Open in Course

Codeforces 295B Greg and Graph - Problem Statement

Codeforces 295B - Reverse F...

You have a complete directed graph with N nodes. Edge weights are given in a matrix. You delete nodes one by one in a specific order.

After each deletion, find the sum of shortest paths between all remaining nodes.

Constraints: N ≤ 500500. Output N numbers: the sums after each deletion step. The small N allows O(N3)O(N^3) total work but you cannot run Floyd-Warshall from scratch after each deletion. You need an incremental approach that reuses previous computations.