# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
894595 | 2023-12-28T13:58:04 Z | lunaTu | Xylophone (JOI18_xylophone) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#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
xylophone.cpp: In function 'void solve2(int)': xylophone.cpp:18:26: error: 'N' was not declared in this scope 18 | for (int i = 3; i <= N; i++) { | ^ xylophone.cpp:19:17: error: reference to 'get' is ambiguous 19 | int x = get[i].ff, y = get[i].ss; | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from xylophone.cpp:1: /usr/include/c++/10/variant:1099:27: note: candidates are: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::variant<_Types ...>&&)' 1099 | constexpr const _Tp&& get(const variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1090:26: note: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::variant<_Types ...>&)' 1090 | constexpr const _Tp& get(const variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1080:21: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::variant<_Types ...>&&)' 1080 | constexpr _Tp&& get(variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1071:20: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::variant<_Types ...>&)' 1071 | constexpr _Tp& get(variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1677:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const std::variant<_Types ...>&&)' 1677 | get(const variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1666:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const std::variant<_Types ...>&)' 1666 | get(const variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1655:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(std::variant<_Types ...>&&)' 1655 | get(variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1644:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(std::variant<_Types ...>&)' 1644 | get(variant<_Types...>& __v) | ^~~ 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 xylophone.cpp:1: /usr/include/c++/10/tuple:1357:5: note: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)' 1357 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: '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:1344:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: '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:1306:5: note: '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:1300:5: note: '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:1294:5: note: '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 | ^~~ 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 xylophone.cpp:1: /usr/include/c++/10/array:360:5: note: '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:351:5: note: '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:343:5: note: '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:334:5: note: '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 | ^~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from xylophone.cpp:1: /usr/include/c++/10/utility:282:5: note: '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:277:5: note: '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:272:5: note: '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:267:5: note: '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:262:5: note: '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:257:5: note: '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:252:5: note: '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:247:5: note: '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:238:5: note: '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:233:5: note: '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:228:5: note: '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:223:5: note: '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 | ^~~ xylophone.cpp:11:16: note: 'std::pair<int, int> get [5001]' 11 | pair<int, int> get[M]; | ^~~ xylophone.cpp:24:33: error: 'y' was not declared in this scope 24 | if (x != r && x != y) a[i] = a[i - 2] + x; | ^ xylophone.cpp:28:32: error: 'y' was not declared in this scope 28 | if (x != r && x != y) a[i] = a[i - 2] - x; | ^ xylophone.cpp: In function 'void solve(int)': xylophone.cpp:47:9: error: reference to 'get' is ambiguous 47 | get[i].ff = query(i - 2, i); | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from xylophone.cpp:1: /usr/include/c++/10/variant:1099:27: note: candidates are: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::variant<_Types ...>&&)' 1099 | constexpr const _Tp&& get(const variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1090:26: note: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::variant<_Types ...>&)' 1090 | constexpr const _Tp& get(const variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1080:21: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::variant<_Types ...>&&)' 1080 | constexpr _Tp&& get(variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1071:20: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::variant<_Types ...>&)' 1071 | constexpr _Tp& get(variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1677:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(const std::variant<_Types ...>&&)' 1677 | get(const variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1666:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(const std::variant<_Types ...>&)' 1666 | get(const variant<_Types...>& __v) | ^~~ /usr/include/c++/10/variant:1655:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >&& std::get(std::variant<_Types ...>&&)' 1655 | get(variant<_Types...>&& __v) | ^~~ /usr/include/c++/10/variant:1644:5: note: 'template<long unsigned int _Np, class ... _Types> constexpr std::variant_alternative_t<_Np, std::variant<_Types ...> >& std::get(std::variant<_Types ...>&)' 1644 | get(variant<_Types...>& __v) | ^~~ 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 xylophone.cpp:1: /usr/include/c++/10/tuple:1357:5: note: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_UTypes ...>&&)' 1357 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1350:5: note: '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:1344:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_UTypes ...>&&)' 1344 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1338:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_UTypes ...>&)' 1338 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/10/tuple:1315:5: note: '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:1306:5: note: '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:1300:5: note: '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:1294:5: note: '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 | ^~~ 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 xylophone.cpp:1: /usr/include/c++/10/array:360:5: note: '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:351:5: note: '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:343:5: note: '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:334:5: note: '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 | ^~~ In file included from /usr/include/c++/10/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from xylophone.cpp:1: /usr/include/c++/10/utility:282:5: note: '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:277:5: note: '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:272:5: note: '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:267:5: note: '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:262:5: note: '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:257:5: note: '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:252:5: note: '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:247:5: note: '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:238:5: note: '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:233:5: note: '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:228:5: note: '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:223:5: note: '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 | ^~~ xylophone.cpp:11:16: note: 'std::pair<int, int> get [5001]' 11 | pair<int, int> get[M]; | ^~~ xylophone.cpp:48:9: error: reference to 'get' is ambiguous 48 | get[i].ss = query(i - 1, i); | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133, from xylophone.cpp:1: /usr/include/c++/10/variant:1099:27: note: candidates are: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::variant<_Types ...>&&)' 1099 | constexpr const _Tp&& get(const variant<_Types