Anybody mind sharing a detailed explanation. I could only come up with the Brute Force approach during the contest.
1 Like
Check out my solution:
BACREP - âBacterial Reproductionâ - heavily-documented code; Editorial-style overview.
3 Likes
Thank you I knew you would answer
1 Like
400 lines
By the way, although I would be seeing your code but from what I could think during the contest, does it have something to do with first doing an Euler Tour(ETT) over the tree and then using either a Segment Tree or Moâs Algorithm to answer each query? I couldnât reach to the âhow-toâ part though, may be there is some neat trick.
Yes - Euler Tour (or DFS) plus Segment Tree is sufficient
2 Likes
Can anybody help me what was the problem in this one ?? CodeChef: Practical coding for everyone
I was hoping 1st subtask to accept