Submission #922581

#TimeUsernameProblemLanguageResultExecution timeMemory
922581tvladm2009Wiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h" #include <iostream> #include <complex> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #include <cassert> #include <queue> #include <stack> #include <deque> #include <random> using namespace std; template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;} template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;} #define files(FILENAME) read(FILENAME); write(FILENAME) #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define left left228 #define right right228 #define y1 y1228 #define mp make_pair #define pb push_back #define y2 y2228 #define rank rank228 using ll = long long; using ld = long double; const string FILENAME = "input"; ll min_total_lenght(vector<int> r, vector<int> b) { vector<int> pos[2]; pos[0] = r; pos[1] = b; vector<pair<int, int>> v; for (auto x: r) { v.pb(mp(x, 0)); } for (auto x: b) { v.pb(mp(x, 1)); } sort(all(v)); vector<ll> dp(sz(v), 1e18); map<int, int> mem; mem[0] = -1; int pr = 0; vector<ll> sum[2]; sum[0].resize(sz(v)); sum[1].resize(sz(v)); for (int i = 0; i < sz(v); i++) { if (i > 0) { sum[0][i] = sum[0][i - 1]; sum[1][i] = sum[1][i - 1]; } sum[v[i].second][i] += v[i].first; if (v[i].second == 1) { pr++; } else { pr--; } int op = v[i].second ^ 1; int ind = lower_bound(all(pos[op]), v[i].first) - pos[op]; ll close = 1e18; for (int d : {ind, ind - 1}) { if (0 <= d && d < sz(pos[d])) { chkmin(close, (ll)abs(pos[op][d] - v[i].x)); } } dp[i] = (i == 0 ? 0 : dp[i - 1]) + close; if (mem.count(pr)) { int l = mem[pr] + 1; ll offset = sum[v[i].second][i] - ((l - 1 >= 0) ? sum[v[i].second][l - 1] : 0); offset -= sum[1 - v[i].second][i] - ((l - 1 >= 0) ? sum[1 - v[i].second][l - 1] : 0); chkmin(dp[i], offset + ((l - i >= 0) ? dp[l - 1] : 0)); } mem[pr] = i; } return dp.back(); }

Compilation message (stderr)

wiring.cpp: In function 'll min_total_lenght(std::vector<int>, std::vector<int>)':
wiring.cpp:75:51: error: no match for 'operator-' (operand types are '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'std::vector<int>')
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~
      |                        |                                  |
      |                        |                                  std::vector<int>
      |                        __gnu_cxx::__normal_iterator<int*, std::vector<int> >
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1026:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(__gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type) const [with _Iterator = int*; _Container = std::vector<int>; __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type = long int]'
 1026 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1026:33: note:   no known conversion for argument 1 from 'std::vector<int>' to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'}
 1026 |       operator-(difference_type __n) const _GLIBCXX_NOEXCEPT
      |                 ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  500 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::reverse_iterator<_Iterator>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1533:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1533 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1533:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::move_iterator<_IteratorL>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from wiring.cpp:3:
/usr/include/c++/10/complex:361:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const std::complex<_Tp>&)'
  361 |     operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:361:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from wiring.cpp:3:
/usr/include/c++/10/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const _Tp&)'
  370 |     operator-(const complex<_Tp>& __x, const _Tp& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:370:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from wiring.cpp:3:
/usr/include/c++/10/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const std::complex<_Tp>&)'
  379 |     operator-(const _Tp& __x, const complex<_Tp>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/complex:379:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   'std::vector<int>' is not derived from 'const std::complex<_Tp>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from wiring.cpp:3:
/usr/include/c++/10/complex:456:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&)'
  456 |     operator-(const complex<_Tp>& __x)
      |     ^~~~~~~~
/usr/include/c++/10/complex:456:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'const std::complex<_Tp>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1164:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
 1164 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1164:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorR, _Container>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1177:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
 1177 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1177:5: note:   template argument deduction/substitution failed:
wiring.cpp:75:59: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   75 |   int ind = lower_bound(all(pos[op]), v[i].first) - pos[op];
      |                                                           ^
wiring.cpp:79:45: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'x'
   79 |     chkmin(close, (ll)abs(pos[op][d] - v[i].x));
      |                                             ^