Worst Bridge on the Way — Solution & Editorial
Binary lifting storing, alongside each 2j-ancestor, the maximum edge on that jump; an LCA walk combines the maxima of O(log N) jumps.
Complexity: O((N + Q) log N)
Binary lifting storing, alongside each 2j-ancestor, the maximum edge on that jump; an LCA walk combines the maxima of O(log N) jumps.
Complexity: O((N + Q) log N)