Editorial for Canada Day Contest 2021 - Fine Art
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:
Hint
There are only possible colours.
Hint
Try putting the coordinates on a grid graph.
Solution
Perform a multisource breadth first search from each of the wool colours to find the closest wool for every possible colour. Now the answer to each query has been calculated.
Time complexity:
Comments