code
#include
using namespace std;
int main() {
// your code goes here
long long int table[1000][1000],prow[1000][1000],pcol[1000][1000],i,j,k,l,m,n,o,p,q,r,s,t;
cin>>m>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>table[i][j];
}
}
for(i=0;i<m;i++)
{
prow[i][n-1]=n;
}
for(i=0;i<n;i++)
{
pcol[m-1][i]=m;
}
for(i=0;i<m;i++)
{
long long int last_col=n;
for(j=n-1;j>=0;j–)
{
if(table[i][j]==0)
{
prow[i][j]=j;
last_col=j;
}
else
{
prow[i][j]=last_col;
}
}
}
for(j=0;j<n;j++)
{
long long int last_col=m;
for(i=m-1;i>=0;i--)
{
if(table[i][j]==0)
{
pcol[i][j]=i;
last_col=i;
}
else
{
pcol[i][j]=last_col;
}
}
}
/* for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<prow[i][j]<<" “;
}
cout<<endl;
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<pcol[i][j]<<” ";
}
cout<<endl;
}*/
long long int x_max=0;
for(i=0;i<m;i++)
{
j=0;
while(j<n)
{
if(table[i][j]==0)
{
j++;
continue;
}
l=prow[i][j];
long long int x_min=1000000;
for(k=j;k<l;k++)
{
o=pcol[i][k];
x_min=min(o-i,x_min);
}
x_min=min(x_min,l-j);
x_max=max(x_min,x_max);
j++;
}
}
cout<<x_max<<endl;
return 0;
}
ISSUE:---->Actually I am facing problem inn ALLONES DP PROBLEM IN THE PRATICE CHALLENGES OF THE COURSE PLEADE HELP ME IN GETTING IN WHICH SPECIAL CASE MY CODE IS GETTING WRONG ANSWER BECAUSE 3 OUT OF 4 TEST CASES ARE PASSING AND ONLY 1 IS REMAINING PLEASE HELP …