I've learned A LOT of optimizations tricks for BFS with this problem. I think that's the fastest BFS I've ever done LOL. A little hint if you are unsure what to do: Try to brute force the solution and optimize it. Eventually, you will get AC. And thanks to the author, for creating this amazing problem.