Submission #829290

# Submission time Handle Problem Language Result Execution time Memory
829290 2023-08-18T08:18:10 Z tolbi Catfish Farm (IOI22_fish) C++17
0 / 100
766 ms 2097152 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "fish.h"

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    vector<vector<ll>> grid(N,vector<ll>(N+1,0));
    for (int i = 0; i < M; ++i)
    {
        grid[X[i]][Y[i]]=W[i];
    }
    vector<vector<vector<ll>>> dp(N,vector<vector<ll>>(N+1,vector<ll>(3,-1)));
    //0 decreasing
    //1 increasing
    //2 increasing, \
    but forbidden to profit from back
    function<ll(int,int,int)> f;
    f = [&](int x, int y, int flag)->int{
        if (dp[x][y][flag]!=-1) return dp[x][y][flag];
        if (flag==1){
            dp[x][y][flag]=0;
            if (y<N){
                ll crr = 0;
                if (x>0) crr = grid[x-1][y];
                dp[x][y][flag]=crr+f(x,y+1,1);
            }
            if (x+1<N){
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,1));
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
            }
        }
        else if (flag==0){
            dp[x][y][flag]=0;
            if (y-1>=0){
                dp[x][y][flag]=grid[x][y-1]+f(x,y-1,0);
            }
            if (x+1<N){
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
                if (y==0){
                    dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,2));
                }
            }
        }
        else {
            dp[x][y][flag]=0;
            if (y<N){
                dp[x][y][flag]=f(x,y+1,2);
            }
            if (x+1<N){
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,1));
                dp[x][y][flag]=max(dp[x][y][flag],f(x+1,y,0));
            }
        }
        if (flag!=0 && x+2<N){
            dp[x][y][flag]=max(dp[x][y][flag],f(x+2,0,1));
        }
        return dp[x][y][flag];
    };
    return f(0,0,2);
}

Compilation message

fish.cpp:15:5: warning: multi-line comment [-Wcomment]
   15 |     //2 increasing, \
      |     ^
# Verdict Execution time Memory Grader output
1 Runtime error 766 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 627 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 615 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 4 ms 1748 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '2136100910'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 4 ms 1748 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '2136100910'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 4 ms 1748 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '2136100910'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 615 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 766 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -