Hey its failing testcase 2 and 3 why is it happening
printed the value of s as well
still failing
u need to decrement 1 after each step (if it is not corner)
check above code that i shared
else if(j!=m-1)
{
s=s-1;
}
already checked pls check my above provided code
thi[quote=βsneha23, post:5, topic:115002β]
else if(j!=m-1) { s=s-1; }
[/quote]
this statement will execute only when all conditions above it fails.
but we want to execute it every time so dont put in else if
.
use only if
#include
#include
using namespace std;
void magicalpark(char a[][1000],int m,int n,int k,int s );
void toggle(char s[],int k);
int main()
{
int k,s,m,n;
cin>>n>>m>>k>>s;
char a[1000][1000];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
magicalpark(a,m,n,k,s);
return 0;
}
void magicalpark(char a[1000][1000],int m,int n,int k,int s )
{
bool success=true;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
char ch=a[i][j];
if(k>s)
{
success=false;
break;
}
else if(ch==β*β)
{
s=s+5;
}
else if(ch==β.β)
{
s=s-2;
}
if(j!=m-1)
{
s=s-1;
}
else
break;
}
}
if(success==true)
{
cout<<βYesβ<<endl<<s;
}
else
{
cout<<βNoβ;
}
}
still not passing test 2 3
check now->
thanks!!
i was making very silly mistakes
will close the doubtthanx for cooperating:)

