Help needed in QTREE SPOJ

Revision en1, by toros, 2018-03-21 00:34:50

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...

Tags qtree, spoj

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English toros 2018-03-21 00:34:50 810 Initial revision (published)