Graph Theory37 sections · 1633 units
Open in Course

Planets Queries I - Lessons

(summary)

Binary lifting is the standard technique for kk-th successor queries. When you see large kk and multiple queries, think powers of 22. It is a pattern you will use often. The preprocessing table can be large: O(nlogn)O(n \log n) space. Make sure you have enough memory.

For n=105n = 10^5, you need about 1717 rows, which is manageable. Bit manipulation makes the query phase clean. Checking each bit of kk directly corresponds to the binary decomposition. Use bitwise AND to test bits.