Submission #1204624

#TimeUsernameProblemLanguageResultExecution timeMemory
1204624tamzidMutating DNA (IOI21_dna)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dna.h" using namespace std; string A,B; vector<int> a_T,a_A,b_T,b_A,diff; void init(std::string a, std::string b) { A = a; B = b; a_A.resize(A.size()+1); b_A.resize(A.size()+1); b_T.resize(A.size()+1); a_T.resize(A.size()+1); diff.resize(A.size()+1); for(int i=0;i<A.size();++i) { a_A[i+1]+=a_A[i]; a_T[i+1]+=a_T[i]; b_A[i+1]+=b_A[i]; b_T[i+1]+=b_T[i]; if(A[i] == 'A') ++a_A[i+1]; else ++a_T[i+1]; if(B[i] == 'A') ++b_A[i+1]; else ++b_T[i+1]; if(a[i] != b[i]) { ++diff[i+1]; } } } int get_distance(int x, int y) { int at = a_T[y+1] - a_T[x]; int aa = a_A[y+1] - a_A[x]; int bt = b_T[y+1] - b_T[x]; int ba = b_A[y+1] - b_A[x]; int difff = diff[y+1] - diff[x]; if(diff & 1) return -1; if(at != bt || aa != ba) return -1; return difff / 2; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:43:17: error: no match for 'operator&' (operand types are 'std::vector<int>' and 'int')
   43 |         if(diff & 1)
      |            ~~~~ ^ ~
      |            |      |
      |            |      int
      |            std::vector<int>
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:66,
                 from dna.cpp:1:
/usr/include/c++/11/bitset:1435:5: note: candidate: 'template<long unsigned int _Nb> std::bitset<_Nb> std::operator&(const std::bitset<_Nb>&, const std::bitset<_Nb>&)'
 1435 |     operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
      |     ^~~~~~~~
/usr/include/c++/11/bitset:1435:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::bitset<_Nb>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/c++/11/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/c++/11/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/c++/11/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/c++/11/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/c++/11/valarray:603,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)'
  411 |     _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/valarray_after.h:411:5: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/valarray:1192:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const std::valarray<_Tp>&, const std::valarray<_Tp>&)'
 1192 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/valarray:1192:1: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/valarray:1192:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)'
 1192 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/valarray:1192:1: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from dna.cpp:1:
/usr/include/c++/11/valarray:1192:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)'
 1192 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/valarray:1192:1: note:   template argument deduction/substitution failed:
dna.cpp:43:19: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
   43 |         if(diff & 1)
      |                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:45,
                 from dna.cpp:1:
/usr/include/c++/11/cstddef:142:3: note: candidate: 'constexpr std::byte std::operator&(std::byte, std::byte)'
  142 |   operator&(byte __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/11/cstddef:142:18: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::byte'
  142 |   operator&(byte __l, byte __r) noexcept
      |             ~~~~~^~~
In file included from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from dna.cpp:1:
/usr/include/c++/11/bits/ios_base.h:83:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator&(std::_Ios_Fmtflags, std::_Ios_Fmtflags)'
   83 |   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:83:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Fmtflags'
   83 |   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/ios_base.h:125:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator&(std::_Ios_Openmode, std::_Ios_Openmode)'
  125 |   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:125:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Openmode'
  125 |   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
      |             ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/ios_base.h:165:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator&(std::_Ios_Iostate, std::_Ios_Iostate)'
  165 |   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/11/bits/ios_base.h:165:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Ios_Iostate'
  165 |   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
      |             ~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/11/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from dna.cpp:1:
/usr/include/c++/11/bits/atomic_base.h:104:3: note: candidate: 'constexpr std::memory_order std::operator&(std::memory_order, std::__memory_order_modifier)'
  104 |   operator&(memory_order __m, __memory_order_modifier __mod)
      |   ^~~~~~~~
/usr/include/c++/11/bits/atomic_base.h:104:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::memory_order'
  104 |   operator&(memory_order __m, __memory_order_modifier __mod)
      |             ~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:105,
                 from dna.cpp:1:
/usr/include/c++/11/future:142:20: note: candidate: 'constexpr std::launch std::operator&(std::launch, std::launch)'
  142 |   constexpr launch operator&(launch __x, launch __y) noexcept
      |                    ^~~~~~~~
/usr/include/c++/11/future:142:37: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::launch'
  142 |   constexpr launch operator&(launch __x, launch __y) noexcept
      |                              ~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:127,
                 from dna.cpp:1:
/usr/include/c++/11/charconv:666:3: note: candidate: 'constexpr std::chars_format std::operator&(std::chars_format, std::chars_format)'
  666 |   operator&(chars_format __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/11/charconv:666:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::chars_format'
  666 |   operator&(chars_format __lhs, chars_format __rhs) noexcept
      |             ~~~~~~~~~~~~~^~~~~