Submission #830620

# Submission time Handle Problem Language Result Execution time Memory
830620 2023-08-19T08:37:25 Z NeroZein Catfish Farm (IOI22_fish) C++17
0 / 100
102 ms 219796 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 302;
int n; 
int a[N][N]; 
int pref[N][N]; 
int max_m, max_n;
long long dp[N][N][N]; 

long long bt(int col, int last, int last2) {
  if (col > max_m) {
    return 0;
  }
  if (last > n || last < 0) {
    return -1e16;
  }
  long long& ret = dp[col][last][last2];
  if (ret != -1) {
    return ret;
  }
  long long sum = 0; 
  long long ps = pref[col][last]; 
  for (int nlast = 0; nlast <= max_n; ++nlast) {
    if (nlast > last2 && nlast > last) sum += a[col - 1][nlast];
    if (nlast <= last) ps -= a[col][nlast];
    if (sum) assert(ps == 0);
    ret = max(ret, bt(col + 1, nlast, last) + sum + ps); 
  }
  return ret;
}

long long max_weights(int N_, int M, vector<int> X, vector<int> Y, vector<int> W) {
  n = N_; 
  for (int i = 0; i < M; ++i) {
    max_m = max(max_m, X[i] + 1); 
    max_n = max(max_n, Y[i] + 1); 
    a[X[i] + 1][Y[i] + 1] = W[i];
  }
  for (int i = 1; i <= max_m; ++i) {
    for (int j = 1; j <= max_n; ++j) {
      pref[i][j] = pref[i][j - 1] + a[i][j];      
    } 
  }
  memset(dp, -1, sizeof dp);
  return bt(1, 0, 0); 
}
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 219796 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '40180481736433'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 215816 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 215836 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 215880 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 215880 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 215880 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 215836 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 219796 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '40180481736433'
2 Halted 0 ms 0 KB -