#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
long long dp[n+2][n+2][2]{};
int sum[n+2][n+2]{};
for(int i = 0; i < m; i++) x[i] += 1;
for(int i = 0; i < m; i++) y[i] += 1;
for(int i = 0; i < m; i++) sum[x[i]][y[i]] += w[i];
long long ans = 0;
for(int i = 1; i <= n+1; i++){
for(int j = 0; j < 2; j++){
dp[0][i][j] = -1e18;
}
}
dp[0][0][1] = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n+1; j++){
for(int k = 0; k <= n+1; k++){
long long now = dp[i-1][j][1];
int cur = k;
while(cur > j) now += sum[i-1][cur--];
cur = j;
while(cur > k) now += sum[i][cur--];
ans = max(ans,now);
if(k > j) dp[i][k][1] = max(dp[i][k][1],now);
else if (k < j){
dp[i][k][0] = max(dp[i][k][0],now);
now -= dp[i-1][j][1];
now += dp[i-1][j][0];
ans = max(ans,now);
dp[i][k][0] = max(dp[i][k][0],now);
}
else{
dp[i][k][1] = max(dp[i][k][1],now);
dp[i][k][0] = max(dp[i][k][0],now);
now -= dp[i-1][j][1];
now += dp[i-1][j][0];
ans = max(ans,now);
dp[i][k][0] = max(dp[i][k][0],now);
dp[i][k][1] = max(dp[i][k][1],now);
}
}
dp[i][n+1][1] = max(dp[i][n+1][1] , dp[i-1][k][1]);
}
}
return ans;
}
// int main(){
// cout << max_weights(5, 4, {0, 1, 4, 3}, {2, 1, 4, 3}, {5, 2, 1, 3}) << '\n';
// }
Compilation message
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:48:57: error: 'k' was not declared in this scope
48 | dp[i][n+1][1] = max(dp[i][n+1][1] , dp[i-1][k][1]);
| ^