Six_Seconds's blog

By Six_Seconds, history, 16 months ago, In English

I have tried different times in different ways to execute an accepted solution but Alas, everytime I failed. I would be eternally grateful if someone could debug my code and say what and where I should change in my code so that I won't get TLE. Here is my code Geting TLE in 1000 x 1000 grids Thanks a lot in advance.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
16 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Have you thought about what the time complexity is of your approach? I see you are running a lot of BFS's in a loop. Ok, that seems to be alright, because there's only one character in the grid that's A. Another concern is the many maps you are using for storing info. They give an extra log factor, with quite a big constant. Try changing them to arrays.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Thanks a lot, brother. I have done everything according to your suggestion and my code got accepted. Here is my Accepted Code

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks, I got stuck on the same.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    So Happy to know that, This blog is still helpful. Some months ago, I thought of deleting this blog. Glad that, I didn't delete the blog.