Ahmed-'s blog

By Ahmed-, history, 12 days ago, In English,

For problem 1114F - Please, another Queries on Array?:

Does someone has an idea why this submission 49746866 gets WA test 3 (with 17M memory) while this one 49746950 gets MLE in the same test (with 256M Memory) where the only difference in the power function (Iterative vs Recursive)?

 
 
 
 

»
12 days ago, # |
Rev. 2   Vote: I like it +14 Vote: I do not like it

In iterative code, you defined p as unsigned int, but in recursive one it is int, so, if we suppose that temp can be negative (because of a wrong in range query, for example), there will be no issues in iterative code, but there will be infinite calls in recursive code (because p < 0).

  • »
    »
    11 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Thank you, that was a silly mistake :D