Problem context and objectives
Mission briefing
Expedition navigator · Safe camps and hazards form a connected world map
Find a valid route while marking every place already explored: Two-Color Grid.
Without visited state, the party loops forever or revisits expensive terrain.
How you win
- 1Recognize when Bipartite graph coloring matches the clues
- 2Keep this true after every move: every processed edge joins opposite colors and every colored node has a consistent color within its component
- 3Reach the result within O(V + E) time and O(V) space
Rules and pressure
- Target cost: O(V + E) time and O(V) space
- State rule: every processed edge joins opposite colors and every colored node has a consistent color within its component
Lesson 1 of 3
Stretch every edge between the blue and amber rails. One node's charge determines the opposite charge for every neighbor.
Your call · Node 0 is blue. Which charge do neighbors 1 and 3 receive?