Start everywhere at once
transcript
A zone has a hundred blocks. You need the way to another zone. Search from each block? That repeats the same work. One search is enough.
Mark every start as seen. Push them all at cost zero. Then run one ordinary search. It behaves as if one hidden start existed.
One search visits 3,438 cells. A search from each block visits 343,800. That is a hundred times as many.
Rings grow from the whole zone. Ring one is next to the zone. The search stops at the first hit.
The starts are all at cost zero. So rings stay in order. The first hit is the nearest. Count the whole ring if asked.
Two starts may touch. Mark them all seen first. A start may be a target. Read the statement for that case.
Many starts, one queue. All at cost zero. Stop at the first ring. Count the ring if asked. Full breakdown in the lecture.