悬线法模板题,见论文
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int N=2005;
int n,m,z,maxl,maxr,l[N][N],r[N][N],h[N][N],ans,a[N][N];
int main()
{
cin>>n;
for (int i = 1;i <= n;i++)
for (int j = 1;j <= n; j++)
scanf("%d",&a[i][j]);
for (int i = 1;i <= n; i++)r[0][1]=n;
for (int i = 1;i <= n; i++)
{
maxl = 1,maxr = n;
for (int j = 1;j <= n;j++)
if (a[i][j])
{
maxl = j+1;
h[i][j] = l[i][j]=0;
}
else
{
h[i][j] = h[i-1][j] + 1;
l[i][j] = max(maxl,l[i-1][j]);
}
for (int j = n;j >= 1;--j)
if (a[i][j])
{
maxr = j-1;
r[i][j] = n;
}
else
{
r[i][j] = min(maxr,r[i-1][j]);
ans = max(ans,(r[i][j]-l[i][j]+1)*h[i][j]);
}
}
cout<<ans;
}