The input gives you integers: the boss of employee , the boss of employee , and so on. Employee is the CEO (root).
Build the tree by setting parent[i] to the given boss. Then build the table as described. Each query asks for up[v][?] where is decomposed into powers of . No need to build an adjacency list for this problem. The parent array is all you need to fill the binary lifting table.