Submission #1075092

# Submission time Handle Problem Language Result Execution time Memory
1075092 2024-08-25T18:14:00 Z Zicrus Catfish Farm (IOI22_fish) C++17
0 / 100
78 ms 47388 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
    
typedef long long ll;
    
int n, m;
vector<int> x, y, w;
vector<vector<pair<int, int>>> f; // y, w
vector<vector<int>> relH;

ll sum(int i, int j) {
    ll res = 0;
    for (int k = 0; k < f[i].size(); k++) {
        if (f[i][k].first < j) res += f[i][k].second;
    }
    return res;
}
    
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N; m = M; x = X; y = Y; w = W;
    int q = 4;
    f = vector<vector<pair<int, int>>>(n);
    relH = vector<vector<int>>(n);
    for (int i = 0; i < m; i++) {
        f[x[i]].push_back({y[i], w[i]});
        if (i > 0) relH[x[i-1]].push_back(y[i]+1);
        if (i < m-1) relH[x[i+1]].push_back(y[i]+1);
    }
    for (int i = 0; i < n; i++) {
        relH[i].resize(q+1);
        sort(f[i].begin(), f[i].end());
        sort(relH[i].begin(), relH[i].end());
    }

    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(q+1, vector<ll>(q+1)));
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= q; j++) {
            for (int j1 = 0; j1 <= q; j1++) {
                for (int k = 0; k <= q; k++) {
                    ll val = dp[i-1][j1][k];
                    if (relH[i-1][j1] > relH[i][j]) val += sum(i, relH[i-1][j1]) - sum(i, relH[i][j]);
                    if (relH[i][j] > max(relH[i-1][j1], k)) val += sum(i-1, relH[i][j]) - sum(i-1, max(relH[i-1][j1], k));
                    dp[i][j][j1] = max(dp[i][j][j1], val);
                }
            }
        }
    }

    ll res = 0;
    for (int j = 0; j <= q; j++) {
        for (int j1 = 0; j1 <= q; j1++) {
            res = max(res, dp[n-1][j][j1]);
        }
    }
    for (int i = n-2; i >= n-5 && i >= 0; i--) {
        for (int j = 0; j <= q; j++) {
            for (int j1 = 0; j1 <= q; j1++) {
                ll val = dp[i][j][j1] + sum(i+1, relH[i][j]);
                res = max(res, val);
            }
        }
    }
    return res;
    return 0;
}
    
#ifdef TEST
#include "grader.cpp"
#endif

Compilation message

fish.cpp: In function 'll sum(int, int)':
fish.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int k = 0; k < f[i].size(); k++) {
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 47388 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 61 ms 46376 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 432 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 432 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 432 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 46376 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 78 ms 47388 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '0'
2 Halted 0 ms 0 KB -