I had submitted the solution for this question (Merciless chef) but it is giving me TLE. I have solved it by first traversing the tree in preorder and obtaining the start and end index of inferior chefs for all the chefs. And then implemented the segment tree(with lazy propagation in range updates) to answer the queries.
Can anybody please give me the reason for the TLE or any optimizations that can be done or any mistakes in my code?
LINK to the code.