Submission #702771

# Submission time Handle Problem Language Result Execution time Memory
702771 2023-02-25T06:14:14 Z acceptify Catfish Farm (IOI22_fish) C++17
14 / 100
52 ms 8108 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mxn = 305;

ll n, m, n2, w[mxn][12], ps[mxn][12], dp[mxn][12][12][12], res = 0;

ll get(ll x, ll y, ll y2) {
    return (y <= y2 ? ps[x][y2] - ps[x][y] : 0);
}

ll calc(ll p, ll h2, ll h1, ll h) {
    return get(p, h1, max(h, h2));
}

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N, m = M, n2 = min(n + 1, 10LL);
    for (int i = 0; i < m; i++) w[X[i] + 1][Y[i] + 1] = W[i];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n2; j++) ps[i][j] = ps[i][j - 1] + w[i][j];
    if (n < 3) return max(ps[1][n2], ps[2][n2]);
    for (int h = 0; h <= n2; h++) for (int h1 = 0; h1 <= n2; h1++) for (int h2 = 0; h2 <= n2; h2++) {
        dp[3][h2][h1][h] = calc(1, 0, h2, h1) + calc(2, h2, h1, h);
    }
    for (int i = 4; i <= n; i++) {
        for (int h = 0; h <= n2; h++) for (int h1 = 0; h1 <= n2; h1++) for (int h2 = 0; h2 <= n2; h2++) {
            for (int h3 = 0; h3 <= n2; h3++) {
                dp[i][h2][h1][h] = max(dp[i][h2][h1][h], dp[i - 1][h3][h2][h1] + calc(i - 1, h2, h1, h));
            }
        }
    }
    for (int h = 0; h <= n2; h++) for (int h1 = 0; h1 <= n2; h1++) for (int h2 = 0; h2 <= n2; h2++) {
        res = max(res, dp[n][h2][h1][h] + calc(n, h1, h, 0));
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 4208 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 52 ms 8108 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 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 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 4 ms 2260 KB Output is correct
10 Correct 12 ms 4436 KB Output is correct
11 Correct 5 ms 2260 KB Output is correct
12 Correct 8 ms 4436 KB Output is correct
13 Correct 2 ms 1328 KB Output is correct
14 Correct 8 ms 4316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 4 ms 2260 KB Output is correct
10 Correct 12 ms 4436 KB Output is correct
11 Correct 5 ms 2260 KB Output is correct
12 Correct 8 ms 4436 KB Output is correct
13 Correct 2 ms 1328 KB Output is correct
14 Correct 8 ms 4316 KB Output is correct
15 Incorrect 8 ms 4308 KB 1st lines differ - on the 1st token, expected: '299', found: '231'
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 4 ms 2260 KB Output is correct
10 Correct 12 ms 4436 KB Output is correct
11 Correct 5 ms 2260 KB Output is correct
12 Correct 8 ms 4436 KB Output is correct
13 Correct 2 ms 1328 KB Output is correct
14 Correct 8 ms 4316 KB Output is correct
15 Incorrect 8 ms 4308 KB 1st lines differ - on the 1st token, expected: '299', found: '231'
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 4208 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -