Submission #1025739

#TimeUsernameProblemLanguageResultExecution timeMemory
1025739DorostWefWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; const int N = 200013; long long dp[N]; long long ps[N]; vector <int> v; bool c[N]; long long min_total_length(std::vector<int> r, std::vector<int> b) { vector <int> blocks; int n = (int)r.size() + (int)b.size(); v.push_back(-1); for (int x : r) v.push_back(x); for (int x : b) v.push_back(x); sort (v.begin(), v.end()); for (int i = 1; i <= n; i++) { if ((*lower_bound (r.begin(), r.end(), v[i])) == v[i]) c[i] = 0; else c[i] = 1; if (i == 0) ps[i] = v[i]; else ps[i] = ps[i - 1] + v[i]; } int cnt = 0; dp[0] = 0; for (int i = 1; i <= n; i++) { if (i == 1 || c[i] != c[i - 1]) { blocks.push_back(cnt); cnt = 0; } cnt++; long long near = INT_MAX; if (c[i] == 0) { int in = lower_bound (b.begin(), b.end(), v[i]) - b.begin(); if (in != (int)b.size()) near = abs (v[i] - b[in]); in--; if (in != -1) near = min (near, abs (v[i] - b[in])); } else { int in = lower_bound (r.begin(), r.end(), v[i]) - r.begin(); if (in != (int)r.size()) near = abs (v[i] - r[in]); in--; if (in != -1) near = min (near, abs (v[i] - r[in])); } dp[i] = dp[i - 1] + near; if (cnt <= blocks.back()) { long long ps1, ps2; ps1 = ps[i] - ps[i - cnt]; ps2 = ps[i - cnt] - ps[i - cnt * 2]; dp[i] = min (dp[i], dp[i - 2 * cnt] + ps1 - ps2); } } return dp[n]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:45:41: error: no matching function for call to 'min(long long int&, int)'
   45 |     near = min (near, abs (v[i] - b[in]));
      |                                         ^
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:45:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |     near = min (near, abs (v[i] - b[in]));
      |                                         ^
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:45:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   45 |     near = min (near, abs (v[i] - b[in]));
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:45:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |     near = min (near, abs (v[i] - b[in]));
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
wiring.cpp:45:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |     near = min (near, abs (v[i] - b[in]));
      |                                         ^
wiring.cpp:52:41: error: no matching function for call to 'min(long long int&, int)'
   52 |     near = min (near, abs (v[i] - r[in]));
      |                                         ^
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:52:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   52 |     near = min (near, abs (v[i] - r[in]));
      |                                         ^
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:52:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   52 |     near = min (near, abs (v[i] - r[in]));
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:52:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |     near = min (near, abs (v[i] - r[in]));
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
wiring.cpp:52:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |     near = min (near, abs (v[i] - r[in]));
      |                                         ^