Please read the new rule regarding the restriction on the use of AI tools. ×

abhavgoel's blog

By abhavgoel, history, 12 months ago, In English

I was learning about binary lifting and solving this problem on cses, it runs fine on smaller visualizable cases, but is failing on every large testcase. Can someone help?Link to problem

==================

code
  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
12 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The problem probably is the fact that you set LOG as ceil(log2(n)), although in the problem description, k <= 10^9 holds true, so your code can only jump n steps (instead of k).