Editorial for Escondidas.
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
USACO OPEN09 Problem 'hideseek' Analysis
by David Benjamin
Representing the network of barns as a graph where each edge has length 1, we can compute the distance to each node using a breadth-first search (BFS). That is, we maintain a queue of nodes to visit and add nodes to the end of it. The distance to a node is one more than the distance to its parent.
Comments