Editorial for COCI '06 Contest 1 #4 Slikar
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.
The constraints in the task were low enough that a minute-by-minute simulation was efficient enough, keeping track of flooded fields and those that the painter could have reached by then.
A more efficient solution first uses breadth-first search to find for all fields the time at which they will become flooded. Another BFS then simulates the painter's movement, taking into account information gathered by the first BFS.
Comments