比赛 |
防止浮躁的小练习v0.5 |
评测结果 |
AAAAAAAAAA |
题目名称 |
传纸条 |
最终得分 |
100 |
用户昵称 |
rewine |
运行时间 |
0.151 s |
代码语言 |
C++ |
内存使用 |
26.13 MiB |
提交时间 |
2016-10-15 20:54:55 |
显示代码纯文本
#pragma warning(disable: 4786)
#pragma G++ optimize ("O2")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <iostream>
#define Max(a,b) (a>b ? a:b)
#define Min(a,b) (a<b ? a:b)
#define Rep(_i,x,y) for(int _i = x; _i <= y;_i++)
using namespace std;
typedef unsigned int lg;
#define MAXX 100009
inline bool read(int &x){
char c=getchar();
while(c!=EOF&&!isdigit(c)) c=getchar();
if(c==EOF) return 0; x=0;
while(isdigit(c)) {
x=x*10+c-'0';
c=getchar();
}
return 1;
}
int a[51][51];
int f[51][51][51][51];
int n,m;
signed main(void) {
freopen("message.in","r",stdin);
freopen("message.out","w",stdout);
read(n);read(m);
Rep(i,1,n)
Rep(j,1,m)
read(a[i][j]);
Rep(i,1,n) Rep(j,1,m) Rep(x,1,n) Rep(y,1,m)
if(i != x || j != y || (i==n&&j==m)) {
f[i][j][x][y] = Max (
Max(f[i-1][j][x-1][y],f[i-1][j][x][y-1]),
Max(f[i][j-1][x-1][y],f[i][j-1][x][y-1])
) + a[i][j] + a[x][y];
//cout<<i <<j<<x<<y <<f[i][j][x][y] <<endl;
}
cout << f[n][m][n][m];
return 0;
}