BZOJ 1084 最大子矩阵

http://www.lydsy.com/JudgeOnline/problem.php?id=1084

 1 #include<algorithm>
2 #include<cstdio>
3 #include<cmath>
4 #include<cstring>
5 #include<iostream>
6 int f[1005][1005],F[1005][1005][11];
7 int sum[10005],sum1[10005],sum2[10005],n,m,K;
9     int t=0,f=1;char ch=getchar();
10     while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
11     while ('0'<=ch&&ch<='9'){t=t*10+ch-'0';ch=getchar();}
12     return t*f;
13 }
14 void sxpianfen1(){
15     for (int i=1;i<=n;i++)
17     for (int i=1;i<=n;i++)
18      for (int k=1;k<=K;k++){
19       f[i][k]=f[i-1][k];
20       for (int j=0;j<i;j++)
21        f[i][k]=std::max(f[i][k],f[j][k-1]+sum[i]-sum[j]);
22     }
23     printf("%d\n",f[n][K]);
24 }
25 void sxpianfen2(){
26     for (int i=1;i<=n;i++){
28         sum1[i]=sum1[i-1]+x;
29         sum2[i]=sum2[i-1]+y;
30     }
31     for (int k=1;k<=K;k++)
32      for (int i=1;i<=n;i++)
33       for (int j=1;j<=n;j++){
34          F[i][j][k]=std::max(F[i-1][j][k],F[i][j-1][k]);
35          for (int l=0;l<i;l++) F[i][j][k]=std::max(F[i][j][k],F[l][j][k-1]+sum1[i]-sum1[l]);
36          for (int l=0;l<j;l++) F[i][j][k]=std::max(F[i][j][k],F[i][l][k-1]+sum2[j]-sum2[l]);
37          if (i==j)
38          for (int l=0;l<i;l++) F[i][j][k]=std::max(F[i][j][k],F[l][l][k-1]+sum1[i]+sum2[j]-sum1[l]-sum2[l]);
39       }
40     printf("%d\n",F[n][n][K]);
41 }
42 int main(){
48 }