How to solve BACREP in October challenge?

We could use LCA if there was no updates in queries .So how to solve that problem for 100 points ?

See e.g. BACREP - Algorithm behind? - #3 by ssjgz (and the rest of that thread).