mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:16:28 +00:00
P1006 [NOIP2008 提高组] 传纸条
R62341478
This commit is contained in:
parent
f929e9d580
commit
3952c7b359
26
Luogu/P1006/P1006.cpp
Normal file
26
Luogu/P1006/P1006.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int n, m, w[55][55], f[55][55][55][55];
|
||||
|
||||
int main() {
|
||||
cin >> m >> n;
|
||||
for (int i = 1; i <= m; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
cin >> w[i][j];
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= m; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
for (int k = i + 1; k <= m; k++) {
|
||||
for (int l = 1; l < j; l++) {
|
||||
f[i][j][k][l] = max({f[i - 1][j][k - 1][l], f[i - 1][j][k][l - 1], f[i][j - 1][k - 1][l], f[i][j - 1][k][l - 1]}) + w[i][j] + w[k][l];
|
||||
if (i == j && k == l) f[i][j][k][l] -= w[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << f[m - 1][n][m][n - 1] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user