답안 #871841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871841 2023-11-11T17:28:15 Z Ludissey 메기 농장 (IOI22_fish) C++17
14 / 100
1000 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int>> a;
vector<vector<int>> fsh;

vector<vector<int>> prefx;
map<pair<int,pair<int,int>>, int> memo;
int N,M;
int dp(int x, int last, int lastlast){
  if(memo.find({x,{last,lastlast}})!=memo.end()) return memo[{x,{last,lastlast}}];
  if(x==N) return memo[{x,{last,lastlast}}]=0;
 
  memo[{x,{last,lastlast}}] = 0;
  for (auto i:fsh[x])
  {
    int c=dp(x+1, i, last);
    if(x>0) c+=max(0LL,prefx[x-1][max(i,lastlast)]-prefx[x-1][last]);
    if(x==N-1) c+=max(0LL,prefx[x][last]-prefx[x][i]);
    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));
  fsh.resize(N+1, vector<int>(1,0));
  prefx.resize(N, vector<int>(N+1,0)); //y+1
  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 x = 0; x < N; x++)
  {
    for (int y = 0; y < N; y++)
    {
       prefx[x][y+1]=a[x][y]+prefx[x][y];
    }
  }
  
  int p=dp(0,0,0);
  return p;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 911 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 790 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 837 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 7 ms 1116 KB Output is correct
10 Correct 81 ms 3924 KB Output is correct
11 Correct 23 ms 1376 KB Output is correct
12 Correct 29 ms 2900 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 15 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 7 ms 1116 KB Output is correct
10 Correct 81 ms 3924 KB Output is correct
11 Correct 23 ms 1376 KB Output is correct
12 Correct 29 ms 2900 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 15 ms 2652 KB Output is correct
15 Correct 3 ms 2140 KB Output is correct
16 Execution timed out 1060 ms 5304 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 7 ms 1116 KB Output is correct
10 Correct 81 ms 3924 KB Output is correct
11 Correct 23 ms 1376 KB Output is correct
12 Correct 29 ms 2900 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 15 ms 2652 KB Output is correct
15 Correct 3 ms 2140 KB Output is correct
16 Execution timed out 1060 ms 5304 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 837 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 911 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -