Codeforces #648 D

I tried exactly what the editorial said. I made all the blocks surrounding B to be #. Then, checked if every G can reach the end or not. Here’s my solution: Submission #82867892 - Codeforces

Question : Problem - D - Codeforces

I still failed pretest 4. Can anyone help and explain what is wrong with my code. Thanks!

1 Like

Approach is correct
my Ac solution

1 Like

Check this:

1
3 3
GG#
G##

1 Like

Ah! Thanks for the help.!!

The simplest approach I guess is, create walls around every “B” and then apply bfs from (n,m) and check if all the "G"s have been visited.

1 Like