Problem: http://www.usaco.org/index.php?page=viewproblem2&cpid=213
For whatever reason, implementing any of the three official editorial solutions is not working out for me, so I am changing tact.
My idea is to store the depths relative to the root for each node, run a DFS and BIT similar to what I used in this problem, add/subtract values to/from the BIT according to a sliding window (e.g. when L = 3 and a node with depth 5 is at the bottom of the sliding window, nodes with depth of at most 8 are at the top), and query all nodes in the window that are ancestors of the node in question.
I would appreciate comments on my method.
Please help, and thanks in advance!