Submission #552538

#TimeUsernameProblemLanguageResultExecution timeMemory
552538timreizinWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h" #include <vector> #include <cmath> using namespace std; using ll = long long; ll min_total_length(vector<int> r, vector<int> b) { vector<vector<ll>> dp(r.size(), vector<ll>(b.size())); for (int i = 0; i < b.size(); ++i) { dp[0][i] = abs(r[0] - b[i]); if (i != 0) dp[0][i] += dp[0][i - 1]; } for (int i = 1; i < r.size(); ++i) { for (int j = 0; j < b.size(); ++j) { dp[i][j] = dp[i - 1][j] + abs(r[i] - b[j]); if (j != 0) { dp[i][j] = min({dp[i][j], dp[i][j - 1] + abs(r[i] - b[j]), dp[i - 1][j - 1] + abs(r[i] - b[j])}); } /*ll sum = 0; for (int k = j - 1; k >= 0; --k) { sum += abs(r[i] - b[k + 1]); dp[i][j] = min(dp[i][j], dp[i - 1][k] + sum); }*/ } } return dp.back().back(); }

Compilation message (stderr)

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < b.size(); ++i)
      |                     ~~^~~~~~~~~~
wiring.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 1; i < r.size(); ++i)
      |                     ~~^~~~~~~~~~
wiring.cpp:19:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for (int j = 0; j < b.size(); ++j)
      |                         ~~^~~~~~~~~~
wiring.cpp:24:112: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   24 |                 dp[i][j] = min({dp[i][j], dp[i][j - 1] + abs(r[i] - b[j]), dp[i - 1][j - 1] + abs(r[i] - b[j])});
      |                                                                                                                ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
wiring.cpp:24:112: note:   candidate expects 2 arguments, 1 provided
   24 |                 dp[i][j] = min({dp[i][j], dp[i][j - 1] + abs(r[i] - b[j]), dp[i - 1][j - 1] + abs(r[i] - b[j])});
      |                                                                                                                ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
wiring.cpp:24:112: note:   candidate expects 3 arguments, 1 provided
   24 |                 dp[i][j] = min({dp[i][j], dp[i][j - 1] + abs(r[i] - b[j]), dp[i - 1][j - 1] + abs(r[i] - b[j])});
      |                                                                                                                ^