Submission #1106032

#TimeUsernameProblemLanguageResultExecution timeMemory
1106032jadai007Nile (IOI24_nile)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "nile.h" using namespace std; vector<int> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E){ int N = W.size(), q = E.size(); vector<tuple<int, int, int>> Ws; vector<int> ans; for(int i = 0; i < N; ++i) Ws.emplace_back(W[i], A[i], B[i]); sort(W.begin(), W.end()); for(int i = 0; i < N; ++i) W[i] = get<0>(Ws[i]), A[i] = get<1>(Ws[i]), B[i] = get<2>(Ws[i]); while(q--){ vector<int> dp(N+1, LLONG_MAX); for(int i = 0; i < N; ++i){ if(i == 0) dp[i] = A[i]; else if(i == 1){ if(W[i] - W[i - 1] <= d) dp[i] = B[i] + B[i - 1]; else dp[i] = dp[i - 1] + A[i]; } else{ dp[i] = dp[i - 1] + A[i]; if(i >= 3) dp[i] = min(dp[i], B[i] + A[i - 1] + B[i - 2] + dp[i - 3]); else dp[i] = min(dp[i], B[i] + A[i - 1] + B[i - 2]); } } ans.push_back(dp[N - 1]); } return ans; }

Compilation message (stderr)

nile.cpp:6:13: error: ambiguating new declaration of 'std::vector<int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)'
    6 | vector<int> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E){
      |             ^~~~~~~~~~~~~~~
In file included from nile.cpp:2:
nile.h:3:24: note: old declaration 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)'
    3 | std::vector<long long> calculate_costs(std::vector<int> W, std::vector<int> A,
      |                        ^~~~~~~~~~~~~~~
nile.cpp: In function 'std::vector<int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:14:29: warning: overflow in conversion from 'long long int' to 'std::vector<int>::value_type' {aka 'int'} changes value from '9223372036854775807' to '-1' [-Woverflow]
   14 |         vector<int> dp(N+1, LLONG_MAX);
      |                             ^~~~~~~~~
nile.cpp:18:39: error: 'd' was not declared in this scope
   18 |                 if(W[i] - W[i - 1] <= d) dp[i] = B[i] + B[i - 1];
      |                                       ^