题意:
。。。
思路:
。。。
double solve() {
f[1][0] = d[1][0];
rep(i, 2, n-1) {
rep(j, 0, i-2) {
f[i][j] = f[i-1][j] + d[i][i-1];
}
f[i][i-1] = inf;
rep(j, 0, i-2) f[i][i-1] = min (f[i][i-1], f[i-1][j]+d[j][i]);
}
double ans = inf;
rep(i, 0, n-3) ans = min (ans, f[n-1][i]+d[i][n-1]);
return min (ans, f[n-1][n-2]+d[n-1][n-2]);
}