da.2396's blog

By da.2396, history, 8 years ago, In English

This ques is solved by DP , and the main idea behind the DP is (considering testers solution — http://codeforces.me/contest/543/submission/11035704)

that either the new coder in the queue will write zero lines of code z[i][j][k] = z[i ^ 1][j][k];

But then the next line just shook me :

z[i][j][k] += z[i][j — 1][k — a[it — 1]];

By which it mean new coder will only take one line as a[it-1] is bugs per line of code .

Now considering a new coder can write lines more than one . Isn't it a bit wrong solution ?

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

No, it doesn't mean that the new coder will write only one line of code. That would be the case if the recurrence was z[i][j][k] += z[i-1][j-1][k-a[it-1]], but that's not the case. Pay attention that i stays the same, it's z[i][j][k] += z[i][j — 1][k — a[it — 1]]. It uses a previously calculated value for the current i.

It's done that way to avoid another extra loop for the amount of lines the current coder will write and fit it into TL.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    god, thank god ! Thanks a lot .Got it now !