Can anybody help me with this task: We have a tree with N verteces(N<=5*10^5). Each edge has got a length Li(Li<=1000). In each iteration we delete one of un-deleted edges and we must tell the longest simple way in each of components. Please, any ideas how does to solve it?