Read the official problem and plan your algorithm. Reveal the explanation and code when you are ready to compare.
Approach
Graph traversal
Bobs Portal Travel: explore states in breadth-first order with a queue, marking each state when it is reached so every vertex and edge is processed only as needed.
Breadth-first searchGraphs
Problem and code
Useful links.
Written by benbenyaojifen. Try the problem first, then compare your approach with the code.
Python records executed lines and locals automatically. For selected values in any language, add // @trace i, total on its own valid line; Python uses # @trace i, total.
StatusReady
Output
No run yet.
Diagnostics
No diagnostics yet.
Each run is isolated and has strict limits. Passing one test does not guarantee the judge will accept the solution.