Dynamic Programming21 sections · 916 units
Open in Course

Codeforces 1741E Sending a Sequence - Transition Case 2

Left End Block

dp[i]=true.dp[i] = \text{true}.

Case 2.2. LL is at the left end of a block The block has the form [L,x1,x2,,xL][L, x_1, x_2, \dots, x_L] and starts at position ii.

• The block length is again L+1L + 1.

• It covers positions i,i+1,,i+L.i, i + 1, \dots, i + L. • The prefix before this block ends at i1.i - 1. This move is valid if • i+Lni + L \le ndp[i1]=truedp[i - 1] = \text{true} If both hold, then dp[i+L]=true.dp[i + L] = \text{true}. You try both cases for every ii from 11 to nn and update dpdp wherever you find a valid split.