Count binary string count

#include
#define ll long long
using namespace std;
ll util(ll n,ll start,ll last,ll **dp)
{
if(start==n)
return 1;
if(dp[start][last]!=-1)
return dp[start][last];
if(last==0)
{
return dp[start][last]=util(n,start+1,0,dp)+util(n,start+1,1,dp);
}
else
{
return dp[start][last]=util(n,start+1,0,dp);
}
}
int main() {
ll t;
cin>>t;
while(t–)
{
ll n;
cin>>n;
ll *dp=new ll[n+1];
for(ll i=0;i<=n;i++)
{
dp[i]=new ll[2];
for(ll j=0;j<2;j++)
{
dp[i][j]=-1;
}
}
cout<<util(n,1,0,dp)+util(n,1,1,dp)<<endl;
}
return 0;
}

why this code is giving bad alloc error

@dakshi
please share your code via ide.codingblocks.com

hi @dakshi
refer this code -->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.