Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

kinitic013's blog

By kinitic013, history, 4 weeks ago, In English

I recently read this blog and tried to implement this data structure in problem 455D - Serega and Fun mentioned in comments but it's getting WA and I can't seem to find any bug in my data structure implementation , I know asking you all to debug my code is not good but it's a desperate move :<(

303760090 In my implementation i havn't stored size of each block as in the problem we are swapping so there's never going to be too many or too less blocks

Spoiler Code
  • Vote: I like it
  • -13
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

One of the issues came from your square root implementation, you are setting l=0,r=5000000001, which in the first iteration we get mid=(5000000001)/2=2500000000 square that and we get integer overflow, you should set r=1000000001 instead.

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I am not even using that in my submission

  • »
    »
    4 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Even better is to start with l = 1 << (__lg(x)/2); r = 2*l;