When checking test cases using custo inputs output is same but does not passes the testcases

#include
using namespace std;
int main() {
int n,m,k,s;
cin>>n>>m>>k>>s;
char a[n][m];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cin>>a[i][j];
}
int i=0;
bool f=0;
while(i<n&&!f)
{
int j=0;
for(j=0;j<m-1;j++)
{
if(a[i][j]==’.’)
s=s-2-1;
else if(a[i][j]==’’)
s=s+4;
else
break;
if(s<k)
{
f=1;
cout<<β€œNo\n”;
}}
if(j==m-1)
{
if(a[i][j]==’.’)
s=s-2;
else if(a[i][j]==’
’)
s=s+5;
}
if(s<k)
{
f=1;
cout<<β€œNo\n”;
}
i++;
}
if(s>=k&&!f)
{
cout<<β€œYes\n”<<s<<endl ;
// cout<<s<<endl;
}
else if(!f)
cout<<β€œNo\n”;
return 0;
}

You need to use the following approach as,
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
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<c-1)
{
s–;
}
}
}

if (s >= k)
{
cout << β€œYes” << endl << s;
}
else
{
cout << β€œNo”;
}

@dakshi
You reopened the doubt
How can I help you ?

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.