Showing Run error but now showing wrong answer (Piyush and Magical Park)

I have tried all the things but still, it is showing wrong answer. Before it is showing run error so I read it that I have to put constraints then it is showing the wrong answer.

My code:

Testcases:
1.WA
2. C
3. C
4. WA
5. WA

You need to simply use the follow the following approach as :
if(s<k)
{
break;
}
if (a[i][j]==’.’)
{
s=s-2;
}
if (a[i][j]==’*’ )
{
s=s+5;
}
if (a[i][j]==’ # ’ )
{
break;
}

				if (j<m-1)
								{
									s--;
								}

It is showing run error in testcase 1,4 and 5…and I don’t know why?