Piyush and magical park

few test cases are not getting passed

Please save your code on ide.codingblocks.com and share its link.

my cb ide does not work well…

this is the code that i wrote
#include
using namespace std;
void magicPark(char a[][100] , int n, int m,int k,int s)
{

for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {	
		if(s<k)
		{
			break;
		}
		
        if(a[i][j]=='.'){
            s-=2;
        }
        else if(a[i][j]=='*'){
            s+=5;
        }
        else if(a[i][j]=='#'){
            break;
        }
        if(j!=(n-1))
            s--;
    }
}

cout<<"yes"<<endl<<s;

}
int main(){
int n, m,k,s;
char a[100][100];
cin>>n>>m>>k>>s;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
magicPark(a , n, m, k, s);
return 0;
}

See the value of s does not decrease by 1 when column is last column i.e. j = m - 1. Also if park[i][j] equals to ‘#’ you just need to break the loop not making the value of flag false. Also suppose if in first row the value of flag remains true but in second row the value of s become less than k then you have print no.
Refer this and check how the conditional statements must go:

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.