Submit solution
Points:
5
Time limit:
2.0s
PyPy 3
4.0s
Memory limit:
256M
PyPy 3
512M
Author:
Problem type
Easter has come (past lol)! To celebrate,
's parents are holding their yearly egg hunt as always. In each room of the house, they hide chocolate eggs that may or may not be reachable behind and around impassible obstacles. . Being a big fan of chocolate, he has decided to efficiently and methodically search each room of the house to find as many eggs as he can. Starting in the top left corner of each room (0,0), he can walk either up, down, left, or right and cannot move through any obstacle. Upon reaching an egg, he will pick it up and add it to his collection. Given the floorplan of the room and the location of every egg and obstacle, help him determine the maximum number of eggs he can collect.Input Specification
The first line of input will contain two integers, and () representing the number of rows and columns respectively.
The next lines will be have characters each, consisting of only .
, X
and e
, representing the map of 's house.
X
represents an impassable obstacle.
.
represents open ground.
e
represents an egg.
Output Specification
A single integer representing the maximum number of eggs
can reach.Sample Input 1
2 3
.Xe
...
Sample Output 1
1
Explanation for Sample Output 1
There is only 1 egg and it is reachable from
's position.Sample Input 2
4 4
..Xe
X...
.X..
eXe.
Sample Output 2
2
Explanation for Sample Output 2
One egg is blocked off by obstacles, so
cannot reach it. The other two are still available.
Comments