Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official. ×

toros's blog

By toros, history, 9 months ago, In English,

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

 
 
 
 
  • Vote: I like it  
  • +3
  • Vote: I do not like it  

»
9 months ago, # |
  Vote: I like it +3 Vote: I do not like it

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.