Submission #121778

#TimeUsernameProblemLanguageResultExecution timeMemory
121778TuGSGeReLWiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#include "wiring.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define mp make_pair #define pub push_back #define pob pop_back() #define ss second #define ff first #define mt make_tuple #define pof pop_front() #define fbo find_by_order #define ook order_of_key #define lb lower_bound #define ub upper_bound typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; using pll = pair <ll, ll>; using pii = pair <int, int>; vector <ll> x, y; ll dp[200002], z = -1, opt, k = 1, hd, st; ll cost(vector <ll> n, int hed, vector <ll> m ) { ll cst = 0; for (int i = hed; i < n.size() - 1; i++) cst += n.back() - n[i]; for (int i = 1; i < m.size(); i++) cst += m[i] - m[0]; cst += max(n.size() - hed, m.size()) * (m[0] - n.back()); return cst; } ll calc(vector <ll> n, vector <ll> m) { if ( dp[opt + hd] == 1e18 ) opt = 0; while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) ) opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back()); return cost(n, opt, m) + min(dp[hd + opt + 1], dp[hd + opt]); } long long min_total_length(vector<int> r, vector<int> b) { int i = 0, j = 0; for (int i1 = 1; i1 <= r.size() + b.size(); i1++) dp[i1] = 1e18; while ( i < r.size() || j < b.size() ) { if ( i != r.size() && (j == b.size() || r[i] < b[j]) ) { if ( z == -1 ) { y.pub(r[i]); } else { if ( z == 1 ) { hd += x.size(); x = y; y.clear(); y.pub(r[i]); opt = x.size() - 1; if ( x.size() ) { st = cost(x, opt, y); dp[k] = calc(x, y); } } else { y.pub(r[i]); st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back()); if ( x.size() ) dp[k] = calc(x, y); } } i++; z = 0; } else { if ( z == -1 ) { y.pub(b[j]); } else { if ( z == 0 ) { hd += x.size(); x = y; opt = x.size() - 1; y.clear(); y.pub(b[j]); if ( x.size() ) { st = cost(x, opt, y) + min(dp[hd + opt], dp[hd + opt + 1]); dp[k] = calc(x, y); } } else { y.pub(b[j]); st = st - max(y.size() - 1ll, x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back()); if ( x.size() ) dp[k] = calc(x, y); } } z = 1; j++; } k++; } return dp[r.size() + b.size()]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int cost(std::vector<long long int>, int, std::vector<long long int>)':
wiring.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = hed; i < n.size() - 1; i++)
                    ~~^~~~~~~~~~~~~~
wiring.cpp:34:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < m.size(); i++)
                  ~~^~~~~~~~~~
wiring.cpp: In function 'long long int calc(std::vector<long long int>, std::vector<long long int>)':
wiring.cpp:47:229: error: no matching function for call to 'max(long long unsigned int, long long int)'
  while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) )
                                                                                                                                                                                                                                     ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
wiring.cpp:47:229: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
  while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) )
                                                                                                                                                                                                                                     ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
wiring.cpp:47:229: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
  while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) )
                                                                                                                                                                                                                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
wiring.cpp:47:229: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) )
                                                                                                                                                                                                                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:47:229: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  while ( opt > 0 && st + min(dp[opt + hd], dp[opt + hd + 1]) > min(dp[opt + hd], dp[opt + hd - 1]) + st + n.back() - n[opt - 1] - max((ll)n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1ll, (ll)m.size()) * (m[0] - n.back()) )
                                                                                                                                                                                                                                     ^
wiring.cpp:48:71: error: no matching function for call to 'max(long long unsigned int, long long int)'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                       ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                       ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                       ^
wiring.cpp:48:131: error: no matching function for call to 'max(long long unsigned int, long long int)'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                                                                                   ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:131: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                                                                                   ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:131: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                                                                                   ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:131: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                                                                                   ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:48:131: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   opt--, st = n.back() - n[opt - 1] - max(n.size() - opt, (ll)m.size()) * (m[0] - n.back()) + max(n.size() - opt + 1, (ll)m.size()) * (m[0] - n.back());
                                                                                                                                   ^
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:56:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i1 = 1; i1 <= r.size() + b.size(); i1++)
                   ~~~^~~~~~~~~~~~~~~~~~~~~~
wiring.cpp:59:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while ( i < r.size() || j < b.size() ) {
          ~~^~~~~~~~~~
wiring.cpp:59:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while ( i < r.size() || j < b.size() ) {
                          ~~^~~~~~~~~~
wiring.cpp:60:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ( i != r.size() && (j == b.size() || r[i] < b[j]) ) {
        ~~^~~~~~~~~~~
wiring.cpp:60:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if ( i != r.size() && (j == b.size() || r[i] < b[j]) ) {
                          ~~^~~~~~~~~~~
wiring.cpp:80:54: error: no matching function for call to 'max(long long unsigned int, long long int)'
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                      ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
wiring.cpp:80:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                      ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
wiring.cpp:80:54: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
wiring.cpp:80:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:80:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                      ^
wiring.cpp:80:110: error: no matching function for call to 'max(long long int, long long unsigned int)'
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                                                                              ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
wiring.cpp:80:110: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
      st = st - max(y.size() - 1ll, (ll)x.size() - opt) * (y[0] - x.back()) + max((ll)y.size(), x.size() - opt) * (y[0] - x.back());
                                                                                                              ^
In file included from /usr/include/c++/7/vector:60:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/