D - Teleport Maze Editorial by spheniscine


This is a rather straightforward application of breadth-first search. However, the warp squares introduce a complication as each “warp group” may contain any number of squares. They are all considered neighbors of each other, forming up to \(O(n^2)\) connections for a group of size \(n\). To solve this, note that once a “warp group” is used, all squares in that warp group will be visited and thus that warp group need not be used any more, so you may clear the list of nodes representing that group.

posted:
last update: