Блог пользователя shubhamphpefy

Автор shubhamphpefy, история, 6 месяцев назад, По-английски

Hey there! Actually I tried to solve this problem on UVA. I submitted this solution on vjudge but it is giving TLE. On local machine it is working for all test cases that I tried. I tried to debug as well initially. Now that I am getting correct answers but TLE as well I don't know what's going wrong. Please Help.

P.S. : This is my first blog entry.

Теги uva, dfs
  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

»
6 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Consider this case:

1
4 5
XXX#X
XIXIX
XIIIX
X@XXX

You are greedily taking the first option that will let you move one square, but this means that you will get stuck on row 2, column 2. Due to the way your code is written (you will make no movement if you have no options, but won't break out of the loop either) this results in an infinite loop.

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Yes! Understood. Thank you so much. I assumed that there will be always single instance of each character in 'IEHOVA' that's not the case actually.There is only one path but can have multiple occurrence of single character.

    Thank you so much for your time.