# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894594 | lunaTu | Xylophone (JOI18_xylophone) | 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 <bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#include "xylophone.h"
typedef long long ll;
using namespace std;
const int M = 5e3 + 1;
int a[M];
pair<int, int> get(M);
void solve2(int n) {
map<int, int> d;
d[0] = 1;
d[a[1]] = 2;
for (int i = 3; i <= N; i++) {
int x = get[i].ff, y = get[i].ss;
int r = abs(a[i - 2] - a[i - 1]);
if (a[i - 2] < a[i - 1]) {
if (x != r && x != y) a[i] = a[i - 2] + x;
else a[i] = a[i - 1] - y;
}
else {
if (x != r && x != y) a[i] = a[i - 2] - x;
else a[i] = a[i - 1] + y;
}
if (d[a[i]]) return;
d[a[i]] = i;
}
int i = 1;
for (auto [x, y] : d) {
answer(y, i);
i++;
}
exit(0);
}
void solve(int N) {
for (int i = 3; i <= N; i++) {
get[i].ff = query(i - 2, i);
get[i].ss = query(i - 1, i);
}
a[1] = 0;
a[2] = query(1, 2);
solve2(N);
a[2] *= -1;
solve2(N);
}
Compilation message (stderr)
xylophone.cpp:11:21: error: no matching function for call to 'std::pair<int, int>::pair(const int&)' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:452:9: note: candidate: 'template<class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>) [with _Args1 = {_Args1 ...}; long unsigned int ..._Indexes1 = {_Indexes1 ...}; _Args2 = {_Args2 ...}; long unsigned int ..._Indexes2 = {_Indexes2 ...}; _T1 = int; _T2 = int]' 452 | pair(tuple<_Args1...>&, tuple<_Args2...>&, | ^~~~ /usr/include/c++/10/bits/stl_pair.h:452:9: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: mismatched types 'std::tuple<_Tps ...>' and 'const int' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:387:9: note: candidate: 'template<class ... _Args1, class ... _Args2> std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>) [with _Args1 = {_Args1 ...}; _Args2 = {_Args2 ...}; _T1 = int; _T2 = int]' 387 | pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); | ^~~~ /usr/include/c++/10/bits/stl_pair.h:387:9: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 3 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:381:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 381 | explicit constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:381:21: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: mismatched types 'std::pair<_T1, _T2>' and 'const int' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:371:12: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 371 | constexpr pair(pair<_U1, _U2>&& __p) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:371:12: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: mismatched types 'std::pair<_T1, _T2>' and 'const int' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:361:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 361 | explicit constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:361:21: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:352:12: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 352 | constexpr pair(_U1&& __x, _U2&& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:352:12: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:343:17: note: candidate: 'template<class _U2, typename std::enable_if<_CopyMovePair<false, int, _U2>(), bool>::type <anonymous> > std::pair<_T1, _T2>::pair(const _T1&, _U2&&) [with _U2 = _U2; typename std::enable_if<std::_PCC<true, _T1, _T2>::_CopyMovePair<false, _T1, _U2>(), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 343 | explicit pair(const _T1& __x, _U2&& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:343:17: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:336:18: note: candidate: 'template<class _U2, typename std::enable_if<_CopyMovePair<true, int, _U2>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&) [with _U2 = _U2; typename std::enable_if<std::_PCC<true, _T1, _T2>::_CopyMovePair<true, _T1, _U2>(), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 336 | constexpr pair(const _T1& __x, _U2&& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:336:18: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:329:27: note: candidate: 'template<class _U1, typename std::enable_if<_MoveCopyPair<false, _U1, int>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&) [with _U1 = _U1; typename std::enable_if<std::_PCC<true, _T1, _T2>::_MoveCopyPair<false, _U1, _T2>(), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 329 | explicit constexpr pair(_U1&& __x, const _T2& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:329:27: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:322:18: note: candidate: 'template<class _U1, typename std::enable_if<_MoveCopyPair<true, _U1, int>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&) [with _U1 = _U1; typename std::enable_if<std::_PCC<true, _T1, _T2>::_MoveCopyPair<true, _U1, _T2>(), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 322 | constexpr pair(_U1&& __x, const _T2& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:322:18: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:315:17: note: candidate: 'constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>&&) [with _T1 = int; _T2 = int]' 315 | constexpr pair(pair&&) = default; ///< Move constructor | ^~~~ /usr/include/c++/10/bits/stl_pair.h:315:22: note: no known conversion for argument 1 from 'const int' to 'std::pair<int, int>&&' 315 | constexpr pair(pair&&) = default; ///< Move constructor | ^~~~~~ /usr/include/c++/10/bits/stl_pair.h:314:17: note: candidate: 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = int; _T2 = int]' 314 | constexpr pair(const pair&) = default; ///< Copy constructor | ^~~~ /usr/include/c++/10/bits/stl_pair.h:314:22: note: no known conversion for argument 1 from 'const int' to 'const std::pair<int, int>&' 314 | constexpr pair(const pair&) = default; ///< Copy constructor | ^~~~~~~~~~~ /usr/include/c++/10/bits/stl_pair.h:309:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 309 | explicit constexpr pair(const pair<_U1, _U2>& __p) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:309:21: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: mismatched types 'const std::pair<_T1, _T2>' and 'const int' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:300:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 300 | constexpr pair(const pair<_U1, _U2>& __p) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:300:19: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: mismatched types 'const std::pair<_T1, _T2>' and 'const int' 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:276:26: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() && (! _ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 276 | explicit constexpr pair(const _T1& __a, const _T2& __b) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:276:26: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:266:17: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() && _ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _U1 = _U1; _U2 = _U2; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 266 | constexpr pair(const _T1& __a, const _T2& __b) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:266:17: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 2 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from xylophone.cpp:1: /usr/include/c++/10/bits/stl_pair.h:245:26: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<std::__and_<std::is_default_constructible<_U1>, std::is_default_constructible<_U2>, std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair() [with _U1 = _U1; _U2 = _U2; typename std::enable_if<std::__and_<std::is_default_constructible<_U1>, std::is_default_constructible<_U2>, std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type <anonymous> = <anonymous>; _T1 = int; _T2 = int]' 245 | explicit constexpr pair() | ^~~~ /usr/include/c++/10/bits/stl_pair.h:245:26: note: template argument deduction/substitution failed: xylophone.cpp:11:21: note: candidate expects 0 arguments, 1 provided 11 | pair<int, int> get(M); | ^ In file included from /usr/include/c++/10/bits/stl_algo