IOI 2009 - Mecho
Problem Link Time Complexity: O(N²log(N²)) Algorithms used: Binary Search, BFS An N * N grid is given in which Mecho (a bear) needs to reach his cave before the bees get him. He wants to leave his position at the last possible moment. Mecho can move to the squares above, below, left and right of him, if it is a grassy patch. The bees follow the same rules. The bees spread from square to square, whereas Mecho moves from square to square. Mecho can enter his cave, but the bees cannot. This problem can be represented as a graph problem, where the squares are nodes in a graph, and edges are drawn between grassy patches. Assuming that Mecho can reach his cave before the bees, it is guaranteed that Mecho can do this if he waits for any time between 0 and x. Here, the optimal answer would be x, since he wants to wait at the last possible moment. Any waiting time greater than x would allow the bees to catch Mecho. From this observation, we find out that we can binary search on the ...