Problem Link : https://cses.fi/problemset/task/1750 Submission Link : https://cses.fi/paste/f2a12df5ba1948a496b5bf/
I am not sure why my code this TLE on one test case (where N and Q are 10^5). I tried doing it using binary Lifting , The matrix A is used to store descendants at 2^j position where j<= 35
I believe the solution should not take more then O(q*35+35*n) steps.
Can someone Please help me out?