#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.