NUSS1017

#include < stdio.h >
#include
< string .h >

int  n, i, j, k, mxa;
bool  f[ 2001 ][ 2001 ];
int  r[ 2001 ][ 2001 ];

int  uu[ 2001 ][ 2001 ];

int  main()
{
    
while(scanf("%d",&n)==1)
    
{
        mxa
=0;
        
for(i=0;i<n;i++)
            
for(j=0;j<n;j++)
                scanf(
"%d",&f[i][j]);
        
///
        for(i=0;i<n;i++)
        
{
            
int c=0;
            
for(j=n-1;j>=0;j--)
            
{
                
if(f[i][j]==0)c++;
                
else
                    c
=0;
                r[i][j]
=c;
            }

        }

        memset(uu,
0,sizeof(uu));
        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(i!=0 && r[i][j]<=r[i-1][j])
                
{
                    
if(r[i][j]==r[i-1][j])
                        uu[i][j]
=uu[i-1][j]+1;
                    
else
                    
{
                        uu[i][j]
=2;
                    
int ii=2;
                    
while(i-ii >=0 && r[i][j]<=r[i-ii][j])
                    
{
                        
if(r[i][j]==r[i-ii][j])
                        
{
                            uu[i][j]
=ii+uu[i-ii][j];
                            
break;
                        }

                        uu[i][j]
++;
                        ii
++;
                    }

                    }

                }

                
else
                    uu[i][j]
=1;
            }

        }

        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(mxa<r[i][j]*uu[i][j])
                    mxa
=r[i][j]*uu[i][j];
            }

        }
//
        for(j=0;j<n;j++)
        
{
            
int c=0;
            
for(i=n-1;i>=0;i--)
            
{
                
if(f[i][j]==0)c++;
                
else
                    c
=0;
                r[i][j]
=c;
            }

        }

        memset(uu,
0,sizeof(uu));
        
for(j=n-1;j>=0;j--)
        
{
            
for(i=0;i<n;i++)
            
{
                
if(j!=n-1 && r[i][j]<=r[i][j+1])
                
{
                    
if(r[i][j]==r[i][j+1])
                        uu[i][j]
=uu[i][j+1]+1;
                    
else
                    
{
                        uu[i][j]
=2;
                    
int ii=2;
                    
while(j+ii <&& r[i][j]<=r[i][j+ii])
                    
{
                        
if(r[i][j]==r[i][j+ii])
                        
{
                            uu[i][j]
=ii+uu[i][j+ii];
                            
break;
                        }

                        uu[i][j]
++;
                        ii
++;
                    }

                    }

                }

                
else
                    uu[i][j]
=1;
            }

        }

        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(mxa<r[i][j]*uu[i][j])
                    mxa
=r[i][j]*uu[i][j];
            }

        }
//
        for(i=0;i<n;i++)
        
{
            
int c=0;
            
for(j=0;j<n;j++)
            
{
                
if(f[i][j]==0)c++;
                
else
                    c
=0;
                r[i][j]
=c;
            }

        }

        memset(uu,
0,sizeof(uu));
        
for(j=0;j<n;j++)
        
{
            
for(i=n-1;i>=0;i--)
            
{
                
if(i!=n-1 && r[i][j]<=r[i+1][j])
                
{
                    
if(r[i][j]==r[i+1][j])
                        uu[i][j]
=uu[i+1][j]+1;
                    
else
                    
{
                        uu[i][j]
=2;
                    
int ii=2;
                    
while(i+ii <&& r[i][j]<=r[i+ii][j])
                    
{
                        
if(r[i][j]==r[i+ii][j])
                        
{
                            uu[i][j]
=ii+uu[i+ii][j];
                            
break;
                        }

                        uu[i][j]
++;
                        ii
++;
                    }

                    }

                }

                
else
                    uu[i][j]
=1;
            }

        }

        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(mxa<r[i][j]*uu[i][j])
                    mxa
=r[i][j]*uu[i][j];
            }

        }
//
        for(j=0;j<n;j++)
        
{
            
int c=0;
            
for(i=0;i<n;i++)
            
{
                
if(f[i][j]==0)c++;
                
else
                    c
=0;
                r[i][j]
=c;
            }

        }

        memset(uu,
0,sizeof(uu));
        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(j!=0 && r[i][j]<=r[i][j-1])
                
{
                    
if(r[i][j]==r[i][j-1])
                        uu[i][j]
=uu[i][j-1]+1;
                    
else
                    
{
                        uu[i][j]
=2;
                    
int ii=2;
                    
while(i-ii >=0 && r[i][j]<=r[i][j-ii])
                    
{
                        
if(r[i][j]==r[i][j-ii])
                        
{
                            uu[i][j]
=ii+uu[i][j-ii];
                            
break;
                        }

                        uu[i][j]
++;
                        ii
++;
                    }

                    }

                }

                
else
                    uu[i][j]
=1;
            }

        }

        
for(i=0;i<n;i++)
        
{
            
for(j=0;j<n;j++)
            
{
                
if(mxa<r[i][j]*uu[i][j])
                    mxa
=r[i][j]*uu[i][j];
            }

        }


        printf(
"%d\n",mxa);
    }

    
return 0;
}

你可能感兴趣的:(NUSS1017)