Submission #702570

# Submission time Handle Problem Language Result Execution time Memory
702570 2023-02-24T12:50:22 Z boris_mihov Catfish Farm (IOI22_fish) C++17
0 / 100
46 ms 8104 KB
#include "fish.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
 
typedef long long llong;
const int MAXN = 300 + 10;
 
int n, m;
int t[MAXN][MAXN];
bool bl[MAXN][10][10][10];
llong dp[MAXN][10][10][10];
llong f(int idx, int curr, int last1, int last2)
{
    if (idx == n + 1)
    {
        return 0;
    }

    if (bl[idx][curr][last1][last2])
    {
        return dp[idx][curr][last1][last2];
    }

    bl[idx][curr][last1][last2] = true;
    dp[idx][curr][last1][last2] = f(idx + 1, 0, curr, last1);

    if (curr < 8)
    {
        llong add = t[curr + 1][idx + 1];
        if (last2 < curr + 1 && last1 < idx - 1)
        {
            add += t[curr + 1][idx - 1];
        }

        if (last1 >= curr + 1)
        {
            add -= t[curr + 1][idx];
        }

        dp[idx][curr][last1][last2] = std::max(dp[idx][curr][last1][last2], f(idx, curr + 1, last1, last2) + add);
    }

    return dp[idx][curr][last1][last2];
}

llong max_weights(int N, int M, std::vector <int> X, std::vector <int> Y, std::vector <int> W) 
{
    n = N; m = M;   
    for (int i = 0 ; i < m ; ++i)
    {
        t[Y[i] + 1][X[i] + 1] = W[i];
    }   
    
    return f(1, 0, 0, 0);
}
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 46 ms 8104 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 3 ms 1612 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '245724665735'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 3 ms 1612 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '245724665735'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 3 ms 1612 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '245724665735'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 4180 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -