Heavy Light Decomposition Implementation

Revision en2, by dx24816, 2018-08-30 17:21:11

Hello,

I was trying to do the USACO problem Grass Planting (http://www.usaco.org/index.php?page=viewproblem2&cpid=102), but couldn't get my Heavy Light Decomposition to work. Can somebody direct me to a Heavy Light Decomposition implementation without LCA? Also, could someone also show me how to implement Heavy Light Decomposition with both the values on vertices and then with the values on the edges? I tried using Al.Cash's implementation, but for some reason, it failed. Thanks!

Edit: I got the edge version to work on the grass planting problem my messing around with Al.Cash's implementation, but can't vertex version to work. I was trying to do Timus 1553 (http://acm.timus.ru/problem.aspx?space=1&num=1553), but keep getting WA on test case 4. I'm pretty sure it's because of my HLD, and I'm not sure what's going on. Can somebody point out my error?

My code (https://ideone.com/k4gvQX)

-dx24816

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English dx24816 2018-08-30 17:21:11 419
en1 English dx24816 2018-08-30 04:01:12 539 Initial revision (published)