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

Автор red_coder, 13 лет назад, По-английски

Hey guys here is a simple problem on BFS of SPOJ. I tried to solve it but getting Run-time error. Here is my Code. At each step i am trying to pick a node from the top of Queue and insert its two children in the queue one appended with 0 and one appended with 1 back in Queue. Could u figure out the error?

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

»
13 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I think it's overflow of long long and, as a result, reference to a negative index of the array. Or size of the array is just too small.

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

Ignore, I was out of my mind obviously. :-)

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

As you can see at link you provided, you receive RE when test is "1 9999".

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

finally got accepted :) Thanks to all of u for ur help