比赛 |
防止isaac的小练习day2 |
评测结果 |
AAAAAA |
题目名称 |
方格取数 |
最终得分 |
100 |
用户昵称 |
蜗牛哲 |
运行时间 |
0.010 s |
代码语言 |
C++ |
内存使用 |
0.93 MiB |
提交时间 |
2016-11-02 11:35:14 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<sstream>
#include<iomanip>
using namespace std;
//=====================struct declaration======================
//=====================var declarartion========================
const int maxn=10+10;
int a[maxn][maxn],f[maxn][maxn][maxn][maxn];
int n,r,s,t,x,y,z;
//=====================function declaration====================
//=====================main code===============================
int main()
{
freopen("fgqs.in","r",stdin);
freopen("fgqs.out","w",stdout);
scanf("%d",&n);
while(1)
{
scanf("%d%d%d",&r,&s,&t); if(r==0) break;
a[r][s]=t;
}
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
for(int i2=1; i2<=n; i2++)
for(int j2=1; j2<=n; j2++)
{
x=max(f[i-1][j][i2-1][j2],f[i-1][j][i2][j2-1]);
y=max(x,f[i][j-1][i2-1][j2]);
z=max(y,f[i][j-1][i2][j2-1]);
if(i==i2 && j==j2)
f[i][j][i2][j2]=z+a[i][j];
else
f[i][j][i2][j2]=z+a[i][j]+a[i2][j2];
}
cout<<f[n][n][n][n]<<endl;
return 0;
}