CSES - Swap Game
Authors: Maggie Liu, Daniel Ge
Hint
The difficulty of this problem is with how we choose to implement the BFS. We present two solutions with the first being faster and the second being easier to write (note that the second solution may TLE). The differences lies with how the grid is hashed.
Solution 1
Solution 2
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!