can you please help me …i am getting wa on some testcases…but i dont know why
here is the link of my solution
https://www.codechef.com/viewsolution/34206931
It shows access denied brother!! Tell me what are you doing in the problem?
1 Like
#include<bits/stdc++.h>
using namespace std;
long long int a[1000][1000];
long long int mini=1e9;
long long int ans=0;
long long int temp=0;
void solve(long long int i,long long int j,long long int n,long long int m)
{
if(i<0 || i>=n || j<0 || j>=m ||a[i][j]!=mini)
{
ans=max(ans,temp);
return;
}
temp++;
a[i][j]=0;
solve(i+1,j,n,m);
solve(i-1,j,n,m);
solve(i,j+1,n,m);
solve(i,j-1,n,m);
}
void find(long long int N,long long int M)
{
for(long long int i=0;i<N;i++)
{
for(long long int j=0;j<M;j++)
{
if(a[i][j]==mini)
{
solve(i,j,N,M);
temp=0;
}
}
}
return;
}
int main()
{
long long int n,m;
cin>>n>>m;
for(long long int i=0;i<n;i++)
{
for(long long int j=0;j<m;j++)
{
cin>>a[i][j];
if(a[i][j]<mini)
{
mini=a[i][j];
}
}
}
find(n,m);
cout<<mini<<" "<<ans;
}
consider this
5 5
1 2 2 2 2
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
ans is 2 9
i hope you will understand your error
read question carefully
1 Like
thanks mate…done
1 Like
isn’t there an editorial for this?