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

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

Can somebody please help me in finding the error in my code for the problem Qtree.
Spent more than 7-8 hours on this, submitted a total of 14 codes and on every submission I got tle. Could not figure out why.
I don't think there is anything wrong with my logic. The complexity of my solution is also nlog2n. I checked every while loop for infinite iterations; didn't find any. I tried some of the available test cases from spoj toolkit but each of them worked fine. Is there a strict time limit or is there something else that I am missing.
Here is my code.
Necessary comments are added in the code for anyone to understand.

Thanks in advance. Help would be much appreciated...

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

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

While taking the string input, you're using cin, make a character array instead and use scanf. I changed scanf to cin in my old code and it got TLE, so maybe this can help.