Submission #632403

# Submission time Handle Problem Language Result Execution time Memory
632403 2022-08-19T23:20:53 Z Olympia Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <fish.h>
using namespace std;
int64_t max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    int my = 0;
    for (int y: Y) {
        my = max(my, y);
    }
    my ++;
    int64_t dp[N + 1][my + 1][my + 1];
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= my; j++) {
            for (int k = 0; k <= my; k++) {
                dp[i][j][k] = -1e18;
            }
        }
    }
    dp[0][0][0] = 0;
    vector<pair<int,int64_t> > vec[N + 10];
    for (int i = 0; i < X.size(); i++) {
        vec[X[i]].push_back(make_pair(Y[i], W[i]));
    }
    for (int i = 1; i <= N; i++) {
        for (int prev2 = 0; prev2 <= my; prev2++) {
            for (int prev1 = 0; prev1 <= my; prev1++) {
                for (int cur = 0; cur <= my; cur++) {
                    int64_t ans = 0;
                    for (auto& p: vec[i + 1]) {
                        ans += p.second * (p.first < cur);
                    }
                    for (auto& p: vec[i]) {
                        ans -= p.second * (p.first < cur && p.first < prev1);
                    }
                    for (auto& p: vec[i - 1]) {
                        ans += p.second * (p.first >= prev1 && p.first < cur && p.first >= prev2);
                    }
                    dp[i][prev1][cur] = max(dp[i - 1][prev2][prev1] + ans, dp[i][prev1][cur]);
                }
            }
        }
    }
    int64_t myMax = 0;
    for (int i = 0; i <= my; i++) {
        for (int j = 0; j <= my; j++) {
            myMax = max(myMax, dp[N][i][j]);
        }
    }
    return myMax;
}


int main () {
    //freopen("gangs.out", "r", stdin);
    int N, M;
    cin >> N >> M;
    vector<int> X, Y, W;
    for (int i = 0; i < M; i++) {
        int x, y, w;
        cin >> x >> y >> w;
        x++;
        X.push_back(x), Y.push_back(y), W.push_back(w);
    }
    cout << max_weights(N, M, X, Y, W);
}

Compilation message

fish.cpp:4:9: error: ambiguating new declaration of 'int64_t max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)'
    4 | int64_t max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
      |         ^~~~~~~~~~~
In file included from fish.cpp:2:
fish.h:3:11: note: old declaration 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)'
    3 | long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
      |           ^~~~~~~~~~~
fish.cpp: In function 'int64_t max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < X.size(); i++) {
      |                     ~~^~~~~~~~~~