# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599210 | definitelynotmee | Mutating DNA (IOI21_dna) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<array<int,3>>(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:31: error: expected primary-expression before '(' token 22 | ct[i] = vector<array<int,3>>(array<int,3>>,{}); | ^ dna.cpp:22:43: error: expected primary-expression before '>' token 22 | ct[i] = vector<array<int,3>>(array<int,3>>,{}); | ^~ dna.cpp:22:45: error: expected primary-expression before ',' token 22 | ct[i] = vector<array<int,3>>(array<int,3>>,{}); | ^ dna.cpp:24:44: error: call of overloaded 'vector(int, <brace-enclosed initializer list>)' is ambiguous 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: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: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()) | ^~~~~~ 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: '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:55, from dna.h:1, from dna.cpp:1: /usr/include/c++/10/bits/basic_string.h:6059: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 _CharT*)' 6059 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6059: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:55, from dna.h:1, from dna.cpp:1: /usr/include/c++/10/bits/basic_string.h:6075: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>&, _CharT)' 6075 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6075: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:55, from dna.h:1, from dna.cpp:1: /usr/include/c++/10/bits/basic_string.h:6087:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 6087 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6087: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 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 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:6093: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>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6093 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6093: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:55, from dna.h:1, from dna.cpp:1: /usr/include/c++/10/bits/basic_string.h:6099:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6099 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6099: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 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 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:6121:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6121 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6121: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:55, from dna.h:1, from dna.cpp:1: /usr/include/c++/10/bits/basic_string.h:6127:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 6127 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6127: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 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 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:6133:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 6133 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/basic_string.h:6133:5: note: template argument deduction/substitution failed: dna.cpp:59:32: note: 'std::array<std::array<int, 3>, 3>::valu