dumbhead's blog

By dumbhead, 7 years ago, In English

I was trying this problem HOLI but I am not able to come up with a good solution. I was thinking of pairing up the leaf nodes of the longest path in the tree. After pairing up, I remove the two paired nodes and continue with the next longest path. But this would give a O(n^2) approach resulting TLE. Can somebody tell me an efficient approach for the solving problem ? I would be happy if somebody helps me in this. Thank you in advance.

Read more »

Tags dfs
 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

By dumbhead, 7 years ago, In English

I was trying this problem SFLIP but I am not able to come up with a solution. Is the intended solution requires a segment tree approach ? I would be happy if somebody helps me in solving this problem ? Thank you in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • +9
  • Vote: I do not like it