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: https://codeforces.com/contest/1365/submission/82867892

Question : https://codeforces.com/contest/1365/problem/D

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
https://codeforces.com/contest/1365/submission/82882874

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