# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548703 | esomer | 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 int long long
vector<tuple<pair<int, int>,pair<int, int>,pair<int, int>>> prefix1;
vector<int> prefix;
int n;
void init(string a, string b) {
int n = a.size();
prefix.resize(n);
prefix1.resize(n);
for(int i = 0; i < n; i++){
if(a[i] == 'T'){
if(i == 0){
get<0> (prefix1[i]).first = 1;
}else{
get<0> (prefix1[i]).first = get<0> (prefix1[i-1]).first + 1;
}
}else if(a[i] == 'A'){
if(i == 0){
get<1> (prefix1[i]).first = 1;
}else{
get<1> (prefix1[i]).first = get<0> (prefix1[i-1]).first + 1;
}
}else{
if(i == 0){
get<2> (prefix1[i]).first = 1;
}else{
get<2> (prefix1[i]).first = get<0> (prefix1[i-1]).first + 1;
}
}
if(b[i] == 'T'){
if(i == 0){
get<0> (prefix1[i]).second = 1;
}else{
get<0> (prefix1[i]).second = get<0> (prefix1[i-1]).second + 1;
}
}else if(b[i] == 'A'){
if(i == 0){
get<1> (prefix1[i]).second = 1;
}else{
get<1> (prefix1[i]).second = get<0> (prefix1[i-1]).second + 1;
}
}else{
if(i == 0){
get<2> (prefix1[i]).second = 1;
}else{
get<2> (prefix1[i]).second = get<0> (prefix1[i-1]).second + 1;
}
}
if(a[i] != b[i]){
if(i == 0) prefix[i] = 1;
else prefix[i] = prefix[i-1] + 1;
}else{
if(i == 0) prefix[i] = 0;
else prefix[i] = prefix[i-1];
}
}
}
int get_distance(int x, int y) {
for(int i = 0; i < 3; i++){
int da;
if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first;
else da = get<i> (prefix1[y]).first;
int db;
if(x > 0) da = get<i> (prefix1[y]).second - get<i> (prefix1[x-1]).second;
else da = get<i> (prefix1[y]).second;
if(da != db) return -1;
}
int d;
if(x > 0) d = prefix[y] - prefix[x-1];
else d = prefix[y];
return d / 2;
}
Compilation message (stderr)
dna.cpp: In function 'long long int get_distance(long long int, long long int)': dna.cpp:68:36: error: no matching function for call to 'get<i>(__gnu_cxx::__alloc_traits<std::allocator<std::tuple<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::pair<long long int, long long int> > >, std::tuple<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::pair<long long int, long long int> > >::value_type&)' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from dna.cpp:2: /usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)' 223 | get(std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:223:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from dna.cpp:2: /usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)' 228 | get(std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:228:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from dna.cpp:2: /usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)' 233 | get(const std::pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/10/utility:233:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from dna.cpp:2: /usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)' 238 | get(const std::pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/10/utility:238:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from dna.cpp:2: /usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)' 247 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:247:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)' 252 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/10/utility:252:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)' 257 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:257:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)' 262 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:262:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)' 267 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:267:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)' 272 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/10/utility:272:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)' 277 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:277:5: note: template argument deduction/substitution failed: /usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)' 282 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/10/utility:282:5: note: template argument deduction/substitution failed: 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:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)' 334 | get(array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:334:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ 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:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)' 343 | get(array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:343:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ 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:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)' 351 | get(const array<_Tp, _Nm>& __arr) noexcept | ^~~ /usr/include/c++/10/array:351:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ 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:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)' 360 | get(const array<_Tp, _Nm>&& __arr) noexcept | ^~~ /usr/include/c++/10/array:360:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included 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/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(std::tuple<_UTypes ...>&)' 1294 | get(tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1294:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included 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/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >& std::get(const std::tuple<_UTypes ...>&)' 1300 | get(const tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1300:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included 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/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(std::tuple<_UTypes ...>&&)' 1306 | get(tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1306:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included 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/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_UTypes ...> >&& std::get(const std::tuple<_UTypes ...>&&)' 1315 | get(const tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: template argument deduction/substitution failed: dna.cpp:68:36: error: the value of 'i' is not usable in a constant expression 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ dna.cpp:66:10: note: 'long long int i' is not const 66 | for(int i = 0; i < 3; i++){ | ^ dna.cpp:68:36: note: in template argument for type 'long unsigned int' 68 | if(x > 0) da = get<i> (prefix1[y]).first - get<i> (prefix1[x-1]).first; | ^ In file included 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/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1344:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_UTypes ...>&)' 1350 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: template argument deduction/substitution failed: /usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)' 1357 | get(const tuple<_Types...>&& _