Understanding the jury's solution in 543A — Writing Code (#302)
Difference between en3 and en4, changed 280 character(s)
For the following problem [problem:543A], the jury's solution↵
[submission:11035704] optimize the DP solution explained in the contest's editorial http://mirror.codeforces.com/blog/entry/17773.↵

I understood the approach explained in the editorial, but what's the intuition behind the optimization and how it works? Specially the lines with bitwise operations:↵


~~~~~↵
    int i = it & 1;↵
        ...↵
        z[i][j][k] = z[i ^ 1][j][k];↵
  ...↵
    ans += z[n & 1][bl][i];↵
  ...↵
~~~~~↵

Just to be clear: I'm not asking about the bitwise operations alone, but also how the original solution in the editorial translated to the jury's code. For example, if you maintain only the two last rows of the DP, how are you going to construct the problem's solution (output)?↵
Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English marlonbymendes 2016-10-26 07:14:51 280
en3 English marlonbymendes 2016-10-26 06:56:26 14
en2 English marlonbymendes 2016-10-26 06:55:46 4
en1 English marlonbymendes 2016-10-26 06:54:42 574 Initial revision (published)