Submission #872310

# Submission time Handle Problem Language Result Execution time Memory
872310 2023-11-12T17:54:31 Z Ludissey Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 36312 KB
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<pair<int,int>, int> a;
vector<vector<int>> fsh;
 
map<pair<int,pair<int,int>>, int> memo;
int N,M;
int dp(int x, int last, int big){
  if(memo.find({x,{last,big}})!=memo.end()) return memo[{x,{last,big}}];
  if(x==N) return 0;
 
  memo[{x,{last,big}}] = 0;
  for (auto i:fsh[x])
  {
    int c=0;
    if(i==0){
      c=dp(x+1, 0, 1);
    } else if(i>=last) {
      if(big==0) break;
      c=dp(x+1, i, 1);
    }else if(i<last){
      c=dp(x+1, i, 0);
    }
    if(x>0) {
      for (int y = last; y < i; y++) {
        if(last!=0) c+=a[{x-1,y}];
      }
      for (int y = i; y < last; y++) {
        c+=a[{x,y}];
      }
    }
    memo[{x,{last,big}}]=max(c, memo[{x,{last,big}}]);
  }
  return memo[{x,{last,big}}];
}
 
long long max_weights(signed n, signed m, std::vector<signed> X, std::vector<signed> Y, std::vector<signed> W) {
  N=n; M=m; 
  fsh.resize(N+1, vector<int>(1,0));
  for (int i = 0; i < M; i++){
    a[{X[i],Y[i]}] = W[i];
    fsh[X[i]+1].push_back(Y[i]+1);
    if(X[i]>0) fsh[X[i]-1].push_back(Y[i]+1);
  }
  for (int i = 0; i < N; i++) sort(fsh[i].begin(),fsh[i].end());
  
  int p=dp(0,0,1);
  return p;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 36312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 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 64 ms 30812 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 0 ms 348 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 0 ms 348 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 0 ms 348 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 64 ms 30812 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 Execution timed out 1059 ms 36312 KB Time limit exceeded
2 Halted 0 ms 0 KB -