Problems > Where Am I After K Jumps > Editorial

Where Am I After K Jumps — Solution & Editorial

Back to the Problem

Binary lifting on the functional graph: up[j][v] = node after 2j jumps. Decompose K into its bits.

Complexity: O((N + Q) log K)