#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;
}
When checking test cases using custo inputs output is same but does not passes the testcases
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β;
}
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.