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

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

Can anyone expain to me why I am getting Memory Limit Exceeded in this problem:- https://codeforces.me/contest/29/problem/D. Here is the link to my submission:- https://codeforces.me/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.

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

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

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.