Submission #892600

# Submission time Handle Problem Language Result Execution time Memory
892600 2023-12-25T15:06:43 Z Trisanu_Das Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
 
long long f_pref[305][305], dp1[305][305], dp2[305][305], dp_pref[305][305], dp_suff[305][305];
 
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
  for(int i = 0; i < M; i++) f_pref[X[i]][Y[i] + 1] = W[i];
  for(int i = 1; i < N; i++) for(int j = 0; j <= N; j++) f_pref[i][j] += f_pref[i][j - 1];
  for(int l = 1; l < N; l++){
    for(int i = 0; i <= N; i++){
      for(int j = 0; j <= N; j++){
        if(i <= j) dp1[i][j] = dp_pref[j][N] + f_pref[l][j] - f_pref[l][i];
        else{
          dp1[i][j] = max(dp_pref[j][j] + f_pref[l - 1][i] - f_pref[l - 1][j], dp_suff[j][i]);
          if(!j) for(int k = j; k < i; k++) dp1[i][j] = max(dp1[i][j], dp_suff[j][k] + f_pref[l - 1][i] - f_pref[l - 1][k]);
        }
      }
    }
    swap(dp1, dp2);
    memset(dp1, 0, sizeof(dp));
    memcpy(dp_pref, dp2, sizeof(dp2));
    memcpy(dp_suff, dp2, sizeof(dp2));
    for(int i = 0; i <= N; i++) for(int j = 1; j <= N; j++) dp_pref[i][j] = max(dp_pref[i][j], dp_pref[i][j - 1]);
    for(int i = 0; i <= N; i++) for(int j = N; j >= 0; j--) dp_suff[i][j] = max(dp_suff[i][j + 1], dp_suff[i][j]);
  }
  long long ans = 0;
  for(int i = 0; i <= N; i++) for(int j = 0; j <= N; j++) ans = max(ans, dp2[i][j]);
  return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:21:27: error: 'dp' was not declared in this scope; did you mean 'dp2'?
   21 |     memset(dp1, 0, sizeof(dp));
      |                           ^~
      |                           dp2