Piyush and Magical Park

#include<bits/stdc++.h>
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];
}
}
bool flag = false;
for(int i=0;i<n;i++){
if(s<k){
flag = false;
break;
}else{
for(int j=0;j<m;j++){
if(a[i][j] == ‘.’){
s = s-2;
s = s-1;
}else if(a[i][j]==’*’){
s = s+5;
s = s-1;
}else{
break;
}
}
}
}
if(s>=k){
flag = true;
}

if(flag){
cout<<“Yes\n”;
cout<<s<<endl;
}else{
cout<<“No\n”;
}
return 0;
}

it is giving error for given test case answer is coming out to be 11 but it should be 13
Pls check once

in problem statement it is given that no strength will bw lost when he is going from last of one row to start of next row, so when you are in column (m-1) do not reduce his strength for walking.i.e (s=s-1) will bw valid when you are not in (m-1)th coulmn.

hey @avinashmallik2017,i guess you had cleared your doubt in this problem if still facing any please let me know,else mark this doubt as resolved,Thankyou.
Regards,
devwrat

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.