ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1081. Binary Lexicographic Sequence

i solved dp[i] - the number of sequences of length i
Posted by >>> 21 Oct 2021 00:48
Re: i solved dp[i] - the number of sequences of length i
Posted by Ivan 23 Jan 2022 01:33
dp[i][j] - amount of i-digit numbers ending with j.

therefore we form 2d table dp[n][2]

then

dp[i][0] = dp[i - 1][0] + dp[i - 1][1]
dp[i][1] = dp[i - 1][1]

It's not hard to see that dp[i][0] + dp[i][1] (i.e. number of all valid sequences) forms a fibonacci sequence.

dp[i][0] + dp[i][1] = 2*dp[i - 1][0] + dp[i - 1][1]
you can treat as f_n = 2*f_(n - 2) + f_(n - 3)

But still, I don't know how to solve this problem :)

Edited by author 23.01.2022 01:36

Edited by author 23.01.2022 01:37
Re: i solved dp[i] - the number of sequences of length i
Posted by So Sui Ming 6 Apr 2024 22:41
dp[i][1] = dp[i - 1][1] is wrong, should be:
dp[i][1] = dp[i - 1][0]