标签:div hit cout bsp span using style return white
//和luogu1004一毛一样有木有
#include<bits/stdc++.h>
using namespace std;
int n,m,ans[60][60],a[60][60][60][60];
int max(int a,int b,int c,int d){
return max(max(a,b),max(c,d));
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)scanf("%d",&ans[i][j]);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
for(int k=1;k<=n;k++)
for(int l=1;l<=m;l++){
a[i][j][k][l]=max(a[i][j-1][k][l-1],a[i-1][j][k-1][l],a[i-1][j][k][l-1],a[i][j-1][k-1][l])+ans[i][j]+ans[k][l];
if(i==k && j==l)a[i][j][k][l]-=ans[i][j];
}
cout<<a[n][m][n][m]<<endl;
return 0;
}
luogu_1006 传纸条
标签:div hit cout bsp span using style return white
原文地址:http://www.cnblogs.com/codetogether/p/7074489.html