POJ-1987 Help

Revision en1, by rguy23, 2024-12-28 08:12:44

Hi everyone, I was trying to solve this problem. You can find my code here. My complexity is $$$O(N \cdot log^2(N))$$$.

However, I am getting TLE. Can someone please help in optimizing my code? I have written appropriate comments in the DFS function. For LCA and Centroid Decomposition, I referred to this blog and took the code from here.

Please help.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rguy23 2024-12-28 08:12:44 541 Initial revision (published)