Submission #569489

#TimeUsernameProblemLanguageResultExecution timeMemory
569489TurkhuuRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> std::vector<long long> minimum_closure_costs(int n, std::vector<int> u, std::vector<int> v, std::vector<int> w){ bool subtask1 = true; for(int i = 0; i < n - 1; i++){ if(u[i] != 0){ subtask1 = false; } } if(subtask1){ sort(w.begin(), w.end()); std::vector<long long> ans(n); for(int i = 0; i < n - 1; i++){ ans[n - i - 2] = ans[n - i - 1] + w[i]; } return ans; } bool subtask2 = true; for(int i = 0; i < n - 1; i++){ if(u[i] != i || v[i] != i + 1){ subtask2 = false; } } if(subtask2){ std::vector<long long> ans(n); ans[0] = accumulate(w.begin(), w.end(), 0LL); vector dp(n, vector<long long>(2)); for(int i = 0; i < n - 1; i++){ dp[i][0] = (i == 0 ? 0 : min(dp[i - 1][0], dp[i - 1][1])) + w[i]; dp[i][1] = (i == 0 ? 0 : dp[i - 1][0]) + w[i]; } ans[1] = min(dp.back()[0], dp.back()[1]); return ans; } return std::vector<long long>(n, 0); }

Compilation message (stderr)

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:27:5: error: 'vector' was not declared in this scope
   27 |     vector dp(n, vector<long long>(2));
      |     ^~~~~~
roads.cpp:27:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from roads.h:1,
                 from roads.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from roads.h:1,
                 from roads.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
roads.cpp:29:7: error: 'dp' was not declared in this scope
   29 |       dp[i][0] = (i == 0 ? 0 : min(dp[i - 1][0], dp[i - 1][1])) + w[i];
      |       ^~
roads.cpp:29:32: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |       dp[i][0] = (i == 0 ? 0 : min(dp[i - 1][0], dp[i - 1][1])) + w[i];
      |                                ^~~
      |                                std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
roads.cpp:32:18: error: 'dp' was not declared in this scope
   32 |     ans[1] = min(dp.back()[0], dp.back()[1]);
      |                  ^~
roads.cpp:32:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   32 |     ans[1] = min(dp.back()[0], dp.back()[1]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~