Hello everyone,
For the recent codeforces round #381, I submitted this code for the div2D/div1B question here. I am not sure why it is wrong...
The basic idea of my code was that I use binary lifting to store the 2^kth ancestor and the distance to the 2^kth ancestor in bparent[][] and bdist[][]. I then binary search for the highest ancestor that each node is controlled by and store the starting and ending points in event[], which i can just dfs and sum up in my function solve().
Could somebody please tell me where I went wrong in my code? Any help would be appreciated.
Thanks!