Count number of binary strings

https://ide.codingblocks.com/s/228341.
why it giving tle in testcase 0 and 1.
How to impliment dp(i.e. what are the states of dp in this ques).