Piyush and magical park

#include
using namespace std;
int main()
{
int M,N,S,K=0;
char arr[100][100];
bool success =true;

// get the inputs;

cin >> M >> N >> K >> S;

//Getting the input array in M x N grid
for (int i =0 ; i < M; i++)
{
for (int j=0; j<N;j++)
{
cin >> arr[i][j];
}
}

//travers the array 
for( int i =0 ; i < M; i++)
{
	for (int j=0 ; j< N; j++)
	{
		char ch = arr[i][j];
	

		if( K>S)
		{
			success = false;
			break;
		}

	 if ( ch == '*')
	 	S += 5;
	else if(ch == '.')
		S -=2;
	else 
		break;
	

	if(j != N-1)
		S--;


	}
}

		if(success == false )
		{
			cout << "No" <<endl;
			cout << S;
		}
		else 
		{
			cout << "Yes" <<endl;
			cout << S;
		}

return 0;

}

when i give the custom input my code is working … when i submit 3 test cases are failed Please advise.

Consider:

4 4 5 10
. . . . 
. # . . 
* * * * 
* # * * 

Expected Output:
No

Your Output:
No
4

There must be hint video on this. Refer that and verify your approach

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.