snap | phone screen | failed | MV
Anonymous User
1514

Imagine we have a forest map represented as 2d array of chars, on which there is:  
A single cell where bear sits initially, marked as 'M'.  
A single bear's den where the bear wants to get to, marked as 'D'.  
Multiple grass cells, marked as 'G'.  
Multiple tree cells, marked as 'T'  
Multiple hive cells with bees, marked as 'H'.  
Rules are the following:  

  1. Every minute a bear can go to a neighbor cell on the north, south, east, west if this cell is not a tree.  
  2. Every minute a bee hive can expand to a neighbor cell on the north, south, east, west if this cell is not a tree and is not a bear's den. The bees are standing in the original position as well.  
    Goal  
    Find the maximum number of minutes the bear can sit before stating moving so that he can get to the bear's den safely without meeting the bees on his path.  
    Example 1  
    MGGD
    GGGG   
    GGGG   
    GHGG  
    answer: 1
Comments (7)