记录编号 | 444552 | 评测结果 | AAAAAA | ||
---|---|---|---|---|---|
题目名称 | [NOIP 2000]方格取数 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.003 s | ||
提交时间 | 2017-09-03 11:22:27 | 内存使用 | 0.93 MiB | ||
#include <iostream> #include<cstdio> #include<cstring> using namespace std; int G[20][20],f[20][20][20][20]; int my_max(int a,int b,int c,int d,int e) { return max(max(max(max(a,b),c),d),e); } int main() { freopen("fgqs.in","r",stdin); freopen("fgqs.out","w",stdout); int n,r,c,v; cin >> n; while (true) { cin >> r >> c >> v; if (r == 0 && c == 0 && v == 0) break; G[r][c] = v; } for (int x1=1;x1<=n;++x1) for (int y1=1;y1<=n;++y1) for (int x2=1;x2<=n;++x2) for (int y2=1;y2<=n;++y2) { f[x1][y1][x2][y2] = my_max(f[x1][y1][x2][y2],f[x1-1][y1][x2-1][y2],f[x1-1][y1][x2][y2-1],f[x1][y1-1][x2-1][y2],f[x1][y1-1][x2][y2-1]); f[x1][y1][x2][y2] += G[x1][y1]; if (x1 != x2 || y1 != y2) f[x1][y1][x2][y2] += G[x2][y2]; } cout << f[n][n][n][n]; return 0; }