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

Автор Forrest_Gump, история, 3 года назад, По-английски

I have commented the code at places. I can't understand why the code gives TLE. 1 test case gives TLE.I have tried to optimise it as much as I could but still TLE. Help would be appreciated. I have used breadth first search to solve the problem.The problem

Also what would be worst case complexity?

Code
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

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

Auto comment: topic has been updated by Forrest_Gump (previous revision, new revision, compare).

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

Try step by step.

Hint
»
3 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

This can Help : CF BLOG Instead of storing string in Queue, try generating it when you arrive at the end, for generation of answer string , you can store (parent child )pair in map(STL). For Hint You can check : My Code