abhavgoel's blog

By abhavgoel, history, 9 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

»
9 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by abhavgoel (previous revision, new revision, compare).

»
9 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).

  • »
    »
    9 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    ahh, changed.. now its working fine. thanks a lot