?
by SSerxhs @ 2021-06-14 12:38:11
哈哈,同款代码
```cpp
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 15;
int a[N][N];
int dp[N][N];
int main()
{
int n, x, y, w;
cin >> n;
while(cin >> x >> y >> w) {
if(x == 0) {
break;
}
a[x][y] = w;
}
dp[1][1]=a[1][1];
for(int step=2;step<2*n;step++)
{
int l=max(1,step-n);
int r=min(n,step);
for(int i=r;i>=l;i--)
{
for(int p=r;p>=i+1;p--)
{
int v=max(max(dp[i][p],dp[i][p-1]),max(dp[i-1][p],dp[i-1][p-1]));
dp[i][p]=v+a[i][step-i]+a[p][step-p];
}
}
}
cout << dp[n-1][n]+a[n][n] << endl;
return 0;
}
```
by start93tjq @ 2021-06-25 19:42:46
2 1 0
2 2 0
1 2 0
数据确实很水,像上面这组数据就说明第一遍走最优路径,掏空之后再走第二遍的方法是错的。比如3楼的程序就是错的,算出来的结果是12,正确答案是10。
by mynamepfd @ 2021-06-28 21:55:02
@[mynamepfd](https://www.luogu.com.cn/user/322773)
输入:
```cpp
2 1 0
2 2 0
1 2 0
```
输出:
```cpp
0
```
by Zhaohongrui @ 2021-09-30 13:17:12