Problem 2850 · Medium

Minimum Moves to Spread Stones Over Grid

Pair each surplus stone with an empty cell by backtracking, pruning any branch whose total Manhattan distance already reaches the best answer.

Open the interactive visualisation