lalalalaaa...'s blog

By lalalalaaa..., history, 4 years ago, In English

I have started solving some problems related to graphs and most of the times i am not able to pass the testcases, either it is TLE or WA. I was solving MONSTERS question from cses Problem Link and was unable to figure to out why some testcases gave TLE.

What i have done-

Applied bfs and stored the min distance between each cell and the monster (M) cell. Applied bfs for A and check whether there was a cell which was having less distance/ or more closer to A than any other M cell. And then checked whether it can reach to any border cell.

Link to My Code

It will be very helpful if anyone can let me know where i am going wrong.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it