Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Dontony's blog

By Dontony, history, 4 years ago, In English

Can anyone expain to me why I am getting Memory Limit Exceeded in this problem:- https://mirror.codeforces.com/contest/29/problem/D. Here is the link to my submission:- https://mirror.codeforces.com/contest/29/submission/111265225.

I just computed the path between each pair of nodes (by inserting 1 at the front and 1 at the back of the leaf list) using lca technique. But getting MLE. Any help? Thanks for devoting your time in reading this.

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

»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

if you want to precompute $$$2^{k th}$$$ ancestors for lca, never run dfs with {node = 1, parent = 0} (you will have 0 as a parent of 1 and may have undefined behaviour), run with {node = 1, parent = 1} instead.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks bro a lot. I got rid of the MLE thing.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The mistake was different. I was computing the lca wrongly.But anyways I will keep your adivice in mind.Thanks.