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

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

Today I wrote a solution for IOI 2010 Traffic

But It exceeds the memory limit.

code

Graph is a tree and has $$$n$$$ $$$( \lt 1e6)$$$ nodes. Therefore i think the total memory will be

  • $$$n$$$ for array p

  • $$$n$$$ each for s and d arrays

  • $$$2*(n-1)$$$ for adjacency vector

  • $$$2*(n-1)$$$ for map m

Complexity is $$$O(n)$$$

But how does this exceeds 250MB? Can someone point me to my mistake.

Thank you.

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

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

You are creating an array called P several times in dp function and this causes ML.

But I guess you don't change anything inside it so I think you don't have to send the array P to the dp function.