Submission #114779

#TimeUsernameProblemLanguageResultExecution timeMemory
114779faustaadpWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h" #include<bits/stdc++.h> typedef long long ll; #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ll n,i,te,d[202020]; pair<ll,ll> a[202020]; ll com(ll aa,ll bb) { ll ii; vector<ll> x,y; for(ii=aa;ii<=bb;ii++) if(a[ii].se==a[aa].se) x.pb(a[ii].fi); else y.pb(a[ii].fi); ll H=0; reverse(x.begin(),x.end()); if(x.size()<y.size()) { for(ii=0;ii<x.size();ii++) H+=abs(x[ii]-y[ii]); for(ii=x.size();ii<y.size();ii++) H+=abs(x[0]-y[ii]); } else { for(ii=0;ii<y.size();ii++) H+=abs(x[ii]-y[ii]); for(ii=y.size();ii<x.size();ii++) H+=abs(y[0]-x[ii]); } //cout<<aa<<" "<<bb<<" "<<H<<"\n"; return H; } ll depe(ll aa) { if(aa==n+1) return 0; if(d[aa]==-1) { d[aa]=1e18; ll ii,udh=0; vector<ll> z; for(ii=aa;ii<=n;ii++) { if(ii>aa&&a[ii].se!=a[ii-1].se) udh=1; if(udh&&a[ii].se==a[aa].se) break; if(udh) { z.pb(ii); if(n!=a[n]) d[aa]=min(d[aa],com(aa,ii)+min(depe(ii+1),depe(ii))); } } ll zs=z.size(); if(zs==1) { for(ii=0;ii<zs;ii++) d[aa]=min(d[aa],com(aa,z[ii])+min(depe(z[ii]+1),depe(z[ii]))); } else if(zs) { // cout<<zs<<" "<<zs/2-1<<" "<<zs/2-1+(zs%2==1)<<"\n"; for(ii=zs/2-1;ii<=zs/2-1+(zs%2==1);ii++) d[aa]=min(d[aa],com(aa,z[ii])+min(depe(z[ii]+1),depe(z[ii]))); } if(zs) for(ii=zs-1;ii<=zs-1;ii++) d[aa]=min(d[aa],com(aa,z[ii])+min(depe(z[ii]+1),depe(z[ii]))); } return d[aa]; } long long min_total_length(std::vector<int> r, std::vector<int> b) { n=r.size()+b.size(); for(i=0;i<r.size();i++) a[++te]=mp(r[i],0); for(i=0;i<b.size();i++) a[++te]=mp(b[i],1); if(r[r.size()-1]<b[0]) return com(1,n); sort(a+1,a+1+te); memset(d,-1,sizeof(d)); return depe(1); }

Compilation message (stderr)

wiring.cpp: In function 'll com(ll, ll)':
wiring.cpp:24:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<x.size();ii++)
            ~~^~~~~~~~~
wiring.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=x.size();ii<y.size();ii++)
                   ~~^~~~~~~~~
wiring.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=0;ii<y.size();ii++)
            ~~^~~~~~~~~
wiring.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ii=y.size();ii<x.size();ii++)
                   ~~^~~~~~~~~
wiring.cpp: In function 'll depe(ll)':
wiring.cpp:57:9: error: no match for 'operator!=' (operand types are 'll {aka long long int}' and 'std::pair<long long int, long long int>')
     if(n!=a[n])
        ~^~~~~~
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:951:5: note: candidate: template<class _BiIter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:951:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1029:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1029:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1109:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1109:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1186:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1186:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1260:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1260:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1337:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)
     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1337:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1417:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)
     operator!=(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1417:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/regex.h:1944:5: note: candidate: template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const std::__cxx11::match_results<_BiIter, _Alloc>&, const std::__cxx11::match_results<_BiIter, _Alloc>&)
     operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1944:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::match_results<_BiIter, _Alloc>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:456:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
     ^~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:456:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::pair<_T1, _T2>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:311:5: note: candidate: template<class _Iterator> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
     operator!=(const reverse_iterator<_Iterator>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:311:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:349:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
     operator!=(const reverse_iterator<_IteratorL>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:349:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:1130:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)
     operator!=(const move_iterator<_IteratorL>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:1130:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:1136:5: note: candidate: template<class _Iterator> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)
     operator!=(const move_iterator<_Iterator>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:1136:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/vector:61:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/allocator.h:158:5: note: candidate: template<class _T1, class _T2> bool std::operator!=(const std::allocator<_Tp1>&, const std::allocator<_T2>&)
     operator!=(const allocator<_T1>&, const allocator<_T2>&)
     ^~~~~~~~
/usr/include/c++/7/bits/allocator.h:158:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::allocator<_Tp1>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/vector:61:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/allocator.h:164:5: note: candidate: template<class _Tp> bool std::operator!=(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
     operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
     ^~~~~~~~
/usr/include/c++/7/bits/allocator.h:164:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::allocator<_Tp1>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/vector:64:0,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1620:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
     operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
     ^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:1620:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/iosfwd:40:0,
                 from /usr/include/c++/7/ios:38,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/postypes.h:221:5: note: candidate: template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
     ^~~~~~~~
/usr/include/c++/7/bits/postypes.h:221:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::fpos<_StateT>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/string_view:468:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)
     operator!=(basic_string_view<_CharT, _Traits> __x,
     ^~~~~~~~
/usr/include/c++/7/string_view:468:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/string_view:474:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >)
     operator!=(basic_string_view<_CharT, _Traits> __x,
     ^~~~~~~~
/usr/include/c++/7/string_view:474:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/bits/basic_string.h:48:0,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/string_view:480:5: note: candidate: template<class _CharT, class _Traits> constexpr bool std::operator!=(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)
     operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
     ^~~~~~~~
/usr/include/c++/7/string_view:480:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/basic_string.h:6044:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:6044:5: note:   template argument deduction/substitution failed:
wiring.cpp:57:14: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'll {aka long long int}'
     if(n!=a[n])
              ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/basic_string.h:6057:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std