Submission #599205

#TimeUsernameProblemLanguageResultExecution timeMemory
599205definitelynotmeeMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using matrix= vector<vector<T>>; array<vector<array<int,3>>,2> ct; vector<array<array<int,3>,3>> fix; map<char,int> dic = {{'A',0},{'C',1},{'T',2}}; void init(std::string a, std::string b) { int n = a.size(); for(int i = 0; i < 2; i++){ ct[i] = vector<int>(array<int,3>>,{}); } fix = vector<array<array<int,3>,3>>(n+1,{{},{},{}}); for(int i = 1; i <= n; i++){ ct[0][i] = ct[i-1]; ct[0][i][dic[a[i-1]]]++; } for(int i = 1; i <= n; i++){ ct[1][i] = ct[i-1]; ct[1][i][dic[b[i-1]]]++; fix[i] = fix[i-1]; fix[i][dic[a[i-1]]][dic[b[i-1]]]++; } } int get_distance(int x, int y) { array<int,3> c1 = ct[0][y+1], c2 = ct[1][y+1]; for(int i = 0; i < 3; i++) c1[i]-=ct[0][x][i], c2[i] -=ct[1][x][i]; if(c1!=c2) return -1; int resp = 0; array<array<int,3>> totfix = fix[y+1]; for(int i = 0; i < 3; i++){ for(int j = 0; j < 3; j++){ totfix[i][j]-=fix[x][i][j]; } } int tricicle = 0; for(int i = 0; i < 3; i++){ for(int j = i+1; j < 3; j++){ int can = min(fix[i][j],fix[j][i]); resp+=can; fix[i][j]-=can; fix[j][i]-=can; tricicle+=fix[i][j]+fix[j][i]; } } resp+=tricicle/3*2; return resp; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:22:22: error: expected primary-expression before '(' token
   22 |   ct[i] = vector<int>(array<int,3>>,{});
      |                      ^
dna.cpp:22:34: error: expected primary-expression before '>' token
   22 |   ct[i] = vector<int>(array<int,3>>,{});
      |                                  ^~
dna.cpp:22:36: error: expected primary-expression before ',' token
   22 |   ct[i] = vector<int>(array<int,3>>,{});
      |                                    ^
dna.cpp:24:52: error: no matching function for call to 'std::vector<std::array<std::array<int, 3>, 3> >::vector(int, <brace-enclosed initializer list>)'
   24 |  fix = vector<array<array<int,3>,3>>(n+1,{{},{},{}});
      |                                                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >]'
  653 |  vector(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:653:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/stl_algobase.h:65,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using _RequireInputIter = std::__enable_if_t<std::is_convertible<typename std::iterator_traits< <template-parameter-1-1> >::iterator_category, std::input_iterator_tag>::value> [with _InIter = int]':
/usr/include/c++/10/bits/stl_vector.h:652:9:   required from here
/usr/include/c++/10/bits/stl_iterator_base_types.h:249:11: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  249 |     using _RequireInputIter =
      |           ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  625 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:625:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::array<std::array<int, 3>, 3> >'
  625 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:607:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::array<std::array<int, 3>, 3> >&&'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >; std::false_type = std::integral_constant<bool, false>]'
  589 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:589:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >; std::true_type = std::integral_constant<bool, true>]'
  585 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:585:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:575:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::array<std::array<int, 3>, 3> >&'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >]'
  572 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:572:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >]'
  553 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:553:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::array<std::array<int, 3>, 3>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  522 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:522:47: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::array<std::array<int, 3>, 3>&'}
  522 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:510:51: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const allocator_type&' {aka 'const std::allocator<std::array<std::array<int, 3>, 3> >&'}
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<std::array<int, 3>, 3> >]'
  497 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:497:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::array<std::array<int, 3>, 3>; _Alloc = std::allocator<std::array<std::array<int, 3>, 3> >]'
  487 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:487:7: note:   candidate expects 0 arguments, 2 provided
dna.cpp:27:20: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'})
   27 |   ct[0][i] = ct[i-1];
      |                    ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 3>& std::array<int, 3>::operator=(const std::array<int, 3>&)'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'} to 'const std::array<int, 3>&'
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 3>& std::array<int, 3>::operator=(std::array<int, 3>&&)'
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'} to 'std::array<int, 3>&&'
dna.cpp:31:20: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 3> >, std::array<int, 3> >::value_type' {aka 'std::array<int, 3>'} and 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'})
   31 |   ct[1][i] = ct[i-1];
      |                    ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 3>& std::array<int, 3>::operator=(const std::array<int, 3>&)'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'} to 'const std::array<int, 3>&'
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 3>& std::array<int, 3>::operator=(std::array<int, 3>&&)'
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from 'std::array<std::vector<std::array<int, 3> >, 2>::value_type' {aka 'std::vector<std::array<int, 3> >'} to 'std::array<int, 3>&&'
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:45:19: error: wrong number of template arguments (1, should be 2)
   45 |  array<array<int,3>> totfix = fix[y+1];
      |                   ^~
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/array:94:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
   94 |     struct array
      |            ^~~~~
dna.cpp:45:38: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::array<std::array<int, 3>, 3> >, std::array<std::array<int, 3>, 3> >::value_type' {aka 'std::array<std::array<int, 3>, 3>'} to 'int' in initialization
   45 |  array<array<int,3>> totfix = fix[y+1];
      |                                      ^
dna.cpp:48:10: error: invalid types 'int[int]' for array subscript
   48 |    totfix[i][j]-=fix[x][i][j];
      |          ^
dna.cpp:55:17: error: cannot convert 'const std::array<int, 3>' to 'int' in initialization
   55 |    int can = min(fix[i][j],fix[j][i]);
      |              ~~~^~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 const std::array<int, 3>
dna.cpp:57:13: error: no match for 'operator-=' (operand types are 'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} and 'int')
   57 |    fix[i][j]-=can;
dna.cpp:58:13: error: no match for 'operator-=' (operand types are 'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} and 'int')
   58 |    fix[j][i]-=can;
dna.cpp:59:23: error: no match for 'operator+' (operand types are 'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} and 'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'})
   59 |    tricicle+=fix[i][j]+fix[j][i];
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:508:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)'
  508 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:508:5: note:   template argument deduction/substitution failed:
dna.cpp:59:32: note:   'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   59 |    tricicle+=fix[i][j]+fix[j][i];
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1540:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)'
 1540 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1540:5: note:   template argument deduction/substitution failed:
dna.cpp:59:32: note:   'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} is not derived from 'const std::move_iterator<_IteratorL>'
   59 |    tricicle+=fix[i][j]+fix[j][i];
      |                                ^
In file included from /usr/include/c++/10/string:55,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6022:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 6022 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6022:5: note:   template argument deduction/substitution failed:
dna.cpp:59:32: note:   'std::array<std::array<int, 3>, 3>::value_type' {aka 'std::array<int, 3>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   59 |    tricicle+=fix[i][j]+fix[j][i];
      |                                ^
In file included from /usr/include/c++/10/string:56,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1160 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note:   template argument deduction/substitution failed:
dna.cpp:59:32: note:   mismatched types 'const _CharT*' and 'std::array<int, 3>'
   59 |    tricicle+=fix[i][j]+fix[j][i];
      |                                ^
In file included from /usr/include/c++/10/string:56,
                 from dna.h:1,
                 from dna.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 1180 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note:   template argument deduction/substitution failed:
dna.cpp:59:32: note: