Today I wrote a solution for IOI 2010 Traffic
But It exceeds the memory limit.
code
Graph is a tree and has $$$n$$$ $$$(<1e6)$$$ nodes. Therefore i think the total memory will be
$$$n$$$ for array
p
$$$n$$$ each for
s
andd
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.