Where is my code wrong?

#include
#include

using namespace std;

int main () {
string s;
int m,l;
cin>>l;
cin>>s;
cin>>m;
bool dp[l][l];
//memset(dp,false,sizeof(dp));
for(int i=0;i<l;i++)
dp[i][i]=true;

int lt,rt;
for(int i=2;i<=l;i++){
	for(int j=0;j<l+1-i;j++){
		lt=j,rt=j+i-1;
		if(i==2)
			dp[lt][rt]=(s[lt]==s[rt]);
		else
			dp[lt][rt]=((s[lt]==s[rt])&&(dp[i+1][j-1]));
	}
}
string arr[m];
for(int i=0;i<m;i++)
{
	cin>>lt;
	cin>>rt;
	if(dp[lt-1][rt-1])
	arr[i]="YES";
	else
	arr[i]="NO";
}

for(int i=0;i<m;i++)
cout<<arr[i]<<endl;

return 0;

}

I mean the test cases while compiling are being solved but during runtime error is being shown.

@Babin
hello Babin,
pls save ur code here - https://ide.codingblocks.com/ and then share the generated link

@Babin
the bug is in the highlighted part
image
it should be dp[lt+1][rt-1]

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.