# F.r.a.n.k.y

dd=====(·▽·*)bლ(╹◡╹ლ)φ(≧ω≦*)♪=￣ω￣=φ(゜▽゜*)♪

## 最大上升子矩阵

1 2 3 4
2 3 4 5
4 5 7 9

5 5
3 1 2 5 7
1 2 3 4 6
2 4 5 6 9
1 5 7 9 7
3 6 8 10 1

1

2 3 4
4 5 6
5 7 9
6 8 10

 1 #include<cstdio>
2 #include<cstring>
3 using namespace std;
4 int n,m,a[1001][1001],left[1001][1001],up[1001][1001],ans,maxx;
5
6 int main()
7 {
8     freopen("matrix.in","r",stdin);
9     freopen("matrix.out","w",stdout);
10     scanf("%d%d",&n,&m);
11     for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) scanf("%d",&a[i][j]);
12     for (int i=1; i<=n; i++)
13         for (int j=1;j<=m;j++)
14         {
15             for (int k=i-1;k>=1;k--)
16                 if (a[k][j]<a[k+1][j]) up[i][j]++;
17                 else break;
18             for (int k=j-1;k>=1;k--)
19                 if (a[i][k]<a[i][k+1]) left[i][j]++;
20                 else break;
21         }
22     maxx=0;
23     for (int i=1; i<=n; i++)
24         for (int j=1; j<=m; j++)
25         {
26             for (int k=up[i][j]+1; k>=1; k--)
27             {
28                 if (k*(left[i][j]+1)<maxx) break;
29                 int l;
30                 ans=left[i][j]+1;
31                 for (l=i; l>=i-k+1; l--)
32                     if (ans>left[l][j]+1) ans=left[l][j]+1;
33                 if (k*ans<maxx) continue;
34                 for (l=j; l>=j-ans+1; l--)
35                     if (up[i][l]+1<k) break;
36                 if (j-l<ans) ans=j-l;
37                 ans=ans*k;
38                 if (ans>maxx) maxx=ans;
39             }
40         }
41     printf("%d",maxx);
42     return 0;
43 } 

posted on 2016-09-25 11:11  Franky==  阅读(629)  评论(0编辑  收藏  举报