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

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

Hello! I tried to solve this problem on SPOJ. Here is my solution. Its showing TLE. Can anyone please help solving this? Thanks

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

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

log2() returns a double. Try __lg().

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

    but i'm getting TLE, not WA.

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

      Yeah, you could be sitting in that while loop on line 49 infinitely if log2() gets rounded the wrong way. In any case, loops like that are scary, and I would certainly try to change it to a for loop if possible, especially if I was getting TLE. Take a look at how the loop is done here.

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

It is multiple testcases, you should clear() your tree before each one. Or better, do not use global variables.