标签:div fine mes out main noi logs ret ++
#include <bits/stdc++.h> #define max4(a,b,c,d) max(max((a),(b)),max((c),(d))) using namespace std; int like[55][55],dp[55][55][55][55]; int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>like[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 y=1;y<=m;y++) if(i==k&&y==j&&(i!=n||j!=m)) continue; else dp[i][j][k][y]=like[i][j]+like[k][y]+max4(dp[i-1][j][k-1][y], dp[i][j-1][k-1][y], dp[i-1][j][k][y-1], dp[i][j-1][k][y-1]); cout<<dp[n][m][n][m]; return 0; }
标签:div fine mes out main noi logs ret ++
原文地址:http://www.cnblogs.com/HC-LittleJian/p/7683402.html