# P1005 [NOIP2007 提高组] 矩阵取数游戏（区间dp+__int128）

f[i][j] = max(f[i - 1][j] + (1 << (m - j + i - 1)) * d[i - 1], f[i][j]);
f[i][j] = max(f[i][j + 1] + (1 << (m - j + i - 1)) * d[j + 1], f[i][j]);


f[i][j] = max(f[i - 1][j] + (d[i - 1] << (m - j + i - 1)), f[i][j]);
f[i][j] = max(f[i][j + 1] + (d[j + 1] << (m - j + i - 1)), f[i][j]);


#include <bits/stdc++.h>

using namespace std;
//-----pre_def----
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define fir(i, a, b) for (int i = a; i <= b; i++)
#define rif(i, a, b) for (int i = a; i >= b; i--)
#define init_h memset(h, -1, sizeof h), idx = 0;
//---------------
const int N = 85;
int n, m;
__int128 f[N][N];
__int128 d[N];
void output(__int128 x)
{
if (x > 9)
output(x / 10);
putchar(x % 10 + '0');
}
{
__int128 x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int StartTime = clock();
#endif
cin >> n >> m;
__int128 ans = 0;
while (n--)
{
memset(f, 0, sizeof f);
fir(i, 1, m)
fir(i, 1, m)
rif(j, m, i)
{
f[i][j] = max(f[i - 1][j] + (d[i - 1] << (m - j + i - 1)), f[i][j]);
f[i][j] = max(f[i][j + 1] + (d[j + 1] << (m - j + i - 1)), f[i][j]);
}

__int128 maxn = 0;
fir(i, 1, m)
maxn = max(maxn, (f[i][i] + (d[i] << m)));
ans += maxn;
}
output(ans);
#ifndef ONLINE_JUDGE
printf("Run_Time = %d ms\n", clock() - StartTime);
#endif
return 0;
}


（还是太菜了 要多刷题）

05-28 890
11-01 1070
10-13 408
06-14 9370
03-19 191
10-29 229
08-30 245
11-16 6696
01-18 293