Submission #871738

# Submission time Handle Problem Language Result Execution time Memory
871738 2023-11-11T12:12:51 Z Ludissey Catfish Farm (IOI22_fish) C++17
0 / 100
859 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
  if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
  if(x==N){
    int c=0;
    for (int y = last; y <= lastlast; y++) c+=a[x-1][y];
    return memo[x][last][lastlast]=c;
  }
 
  memo[x][last][lastlast] = 0;
  for (int i = 0; i < min(10LL,N); i++)
  {
    int c=dp(x+1, i, last);
    if(x>0) for (int y = last; y <= max(i,lastlast); y++) c+=a[x-1][y];
    memo[x][last][lastlast]=max(c, memo[x][last][lastlast]);
  }
  return memo[x][last][lastlast];
}
 
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
  N=n; M=m; 
  a.resize(N, vector<int>(N,0));
  memo.resize(N+1, vector<vector<int>>(N+1, vector<int>(N+1,-1)));
  for (int i = 0; i < M; i++){
    a[X[i]][Y[i]] = W[i];
  }
  int p=dp(0,0,0);
  return p;
}
/*
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
  if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
  if(x==N){
    int c=0;
    for (int y = last; y <= lastlast; y++) c+=a[x-1][y];
    return memo[x][last][lastlast]=c;
  }
 
  memo[x][last][lastlast] = 0;
  for (int i = 0; i < N; i++)
  {
    if(i>0&&x>0&&a[x-1][i]==0) continue;
    int c=dp(x+1, i, last);
    if(x>0) for (int y = last; y <= max(i,lastlast); y++) c+=a[x-1][y];
    memo[x][last][lastlast]=max(c, memo[x][last][lastlast]);
  }
  return memo[x][last][lastlast];
}
 
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
  N=n; M=m; 
  a.resize(N, vector<int>(N,0));
  memo.resize(N+1, vector<vector<int>>(N+1, vector<int>(N+1,-1)));
  for (int i = 0; i < M; i++){
    a[X[i]][Y[i]] = W[i];
  }
  int p=dp(0,0,0);
  return p;
}
*/
/*
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<vector<int>>> memo;
int N,M;
int dp(int x, int last, int lastlast){
  if(memo[x][last][lastlast]!=-1) return memo[x][last][lastlast];
  if(x==N){
    int c=0;
    for (int y = last; y <= lastlast; y++) c+=a[x-1][y];
    return memo[x][last][lastlast]=c;
  }
 
  memo[x][last][lastlast] = 0;
  for (int i = 0; i < N; i++)
  {
    if(i>0&&x>0&&a[x-1][i]==0) continue;
    int c=dp(x+1, i, last);
    if(x>0) for (int y = last; y <= max(i,lastlast); y++) c+=a[x-1][y];
    memo[x][last][lastlast]=max(c, memo[x][last][lastlast]);
  }
  return memo[x][last][lastlast];
}
 
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
  N=n; M=m; 
  a.resize(N, vector<int>(N,0));
  memo.resize(N+1, vector<vector<int>>(N+1, vector<int>(N+1,-1)));
  for (int i = 0; i < M; i++){
    a[X[i]][Y[i]] = W[i];
  }
  int p=dp(0,0,0);
  return p;
}
*/
# Verdict Execution time Memory Grader output
1 Runtime error 859 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 804 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 759 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 14 ms 28252 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '220242990393'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 14 ms 28252 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '220242990393'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 14 ms 28252 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '220242990393'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 759 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 859 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -