Exactly K Flights — Solution & Editorial
Min-plus (tropical) matrix power: replace (+, ×) with (min, +); AK under this semiring gives cheapest exactly-K-edge walks. Same binary exponentiation skeleton.
Complexity: O(N3 log K)
Watch out: The identity element is the INF-off-diagonal matrix (0 on the diagonal), not the all-zero matrix.