CSES Planet Query — 1

Revision en1, by sujal22514, 2024-07-16 17:07:17

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?

Tags binary lifting, cses

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English sujal22514 2024-07-16 17:08:02 3
en1 English sujal22514 2024-07-16 17:07:17 438 Initial revision (published)