# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766009 | 2023-06-25T08:44:29 Z | ono_de206 | Mechanical Doll (IOI18_doll) | C++14 | Compilation error |
0 ms | 0 KB |
#include "doll.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second // #define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; void create_circuit(int m, std::vector<int> a) { int n = a.size(); vector<int> c(m + 1, 0), x, y; vector<vector<int>> g(m + 1); a.pb(0); g[0].pb(a[0]); for(int i = 0; i < n; i++) { g[a[i]].pb(a[i + 1]); } auto add = [&](int X, int Y) -> int { x.pb(X); y.pb(Y); return -(int)x.size(); }; for(int i = 0; i <= m; i++) { int sz = g[i].size(); if(sz == 0) continue; int tmp = 1; while(tmp * 2 < sz) tmp *= 2; while(g[i].size() < tmp) g[i].pb(0); vector<int> tmp; while(g[i].size() > 1) { for(int j = 0; j < g[i].size(); j += 2) { tmp.pb(add(g[i][j], g[i][j + 1])); } swap(tmp, g[i]); } c[i] = g[i][0]; } answer(c, x, y); }
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)': doll.cpp:42:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 42 | while(g[i].size() < tmp) g[i].pb(0); | ~~~~~~~~~~~~^~~~~ doll.cpp:43:15: error: conflicting declaration 'std::vector<int> tmp' 43 | vector<int> tmp; | ^~~ doll.cpp:40:7: note: previous declaration as 'int tmp' 40 | int tmp = 1; | ^~~ doll.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 45 | for(int j = 0; j < g[i].size(); j += 2) { | ~~^~~~~~~~~~~~~ doll.cpp:7:12: error: request for member 'push_back' in 'tmp', which is of non-class type 'int' 7 | #define pb push_back | ^~~~~~~~~ doll.cpp:46:9: note: in expansion of macro 'pb' 46 | tmp.pb(add(g[i][j], g[i][j + 1])); | ^~ doll.cpp:48:18: error: no matching function for call to 'swap(int&, __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from doll.cpp:2: /usr/include/c++/10/sstream:849:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&)' 849 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/10/sstream:849:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from doll.cpp:2: /usr/include/c++/10/sstream:856:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&)' 856 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/10/sstream:856:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from doll.cpp:2: /usr/include/c++/10/sstream:863:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&)' 863 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/10/sstream:863:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from doll.cpp:2: /usr/include/c++/10/sstream:870:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&)' 870 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/10/sstream:870:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/regex:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110, from doll.cpp:2: /usr/include/c++/10/bits/regex.h:849:5: note: candidate: 'template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&)' 849 | swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, | ^~~~ /usr/include/c++/10/bits/regex.h:849:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/regex:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110, from doll.cpp:2: /usr/include/c++/10/bits/regex.h:2141:5: note: candidate: 'template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(std::__cxx11::match_results<_BiIter, _Alloc>&, std::__cxx11::match_results<_BiIter, _Alloc>&)' 2141 | swap(match_results<_Bi_iter, _Alloc>& __lhs, | ^~~~ /usr/include/c++/10/bits/regex.h:2141:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::match_results<_BiIter, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/vector:60, from doll.h:3, from doll.cpp:1: /usr/include/c++/10/bits/move.h:189:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)' 189 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/10/bits/move.h:189:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: deduced conflicting types for parameter '_Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'}) 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/bits/stl_pair.h:59, from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/vector:60, from doll.h:3, from doll.cpp:1: /usr/include/c++/10/bits/move.h:213:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<std::__is_swappable<_Tp>::value> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 213 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/10/bits/move.h:213:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types '_Tp [_Nm]' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:64, from /usr/include/c++/10/vector:60, from doll.h:3, from doll.cpp:1: /usr/include/c++/10/bits/stl_pair.h:533:5: note: candidate: 'template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)' 533 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/10/bits/stl_pair.h:533:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::pair<_T1, _T2>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/vector:67, from doll.h:3, from doll.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1962:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::vector<_Tp, _Alloc>&, std::vector<_Tp, _Alloc>&)' 1962 | swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) | ^~~~ /usr/include/c++/10/bits/stl_vector.h:1962:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/vector:68, from doll.h:3, from doll.cpp:1: /usr/include/c++/10/bits/stl_bvector.h:118:3: note: candidate: 'void std::swap(std::_Bit_reference, std::_Bit_reference)' 118 | swap(_Bit_reference __x, _Bit_reference __y) noexcept | ^~~~ /usr/include/c++/10/bits/stl_bvector.h:118:23: note: no known conversion for argument 1 from 'int' to 'std::_Bit_reference' 118 | swap(_Bit_reference __x, _Bit_reference __y) noexcept | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_bvector.h:126:3: note: candidate: 'void std::swap(std::_Bit_reference, bool&)' 126 | swap(_Bit_reference __x, bool& __y) noexcept | ^~~~ /usr/include/c++/10/bits/stl_bvector.h:126:23: note: no known conversion for argument 1 from 'int' to 'std::_Bit_reference' 126 | swap(_Bit_reference __x, bool& __y) noexcept | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_bvector.h:134:3: note: candidate: 'void std::swap(bool&, std::_Bit_reference)' 134 | swap(bool& __x, _Bit_reference __y) noexcept | ^~~~ /usr/include/c++/10/bits/stl_bvector.h:134:34: note: no known conversion for argument 2 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::_Bit_reference' 134 | swap(bool& __x, _Bit_reference __y) noexcept | ~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/10/string:55, from /usr/include/c++/10/bits/locale_classes.h:40, from /usr/include/c++/10/bits/ios_base.h:41, from /usr/include/c++/10/ios:42, from /usr/include/c++/10/istream:38, from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from doll.cpp:2: /usr/include/c++/10/bits/basic_string.h:6420:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)' 6420 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/10/bits/basic_string.h:6420:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/deque:67, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68, from doll.cpp:2: /usr/include/c++/10/bits/stl_deque.h:2311:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::deque<_Tp, _Alloc>&, std::deque<_Tp, _Alloc>&)' 2311 | swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) | ^~~~ /usr/include/c++/10/bits/stl_deque.h:2311:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::deque<_Tp, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70, from doll.cpp:2: /usr/include/c++/10/fstream:1264:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_filebuf<_CharT, _Traits>&, std::basic_filebuf<_CharT, _Traits>&)' 1264 | swap(basic_filebuf<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/10/fstream:1264:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::basic_filebuf<_CharT, _Traits>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70, from doll.cpp:2: /usr/include/c++/10/fstream:1271:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ifstream<_CharT, _Traits>&, std::basic_ifstream<_CharT, _Traits>&)' 1271 | swap(basic_ifstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/10/fstream:1271:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::basic_ifstream<_CharT, _Traits>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70, from doll.cpp:2: /usr/include/c++/10/fstream:1278:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_ofstream<_CharT, _Traits>&, std::basic_ofstream<_CharT, _Traits>&)' 1278 | swap(basic_ofstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/10/fstream:1278:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::basic_ofstream<_CharT, _Traits>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:70, from doll.cpp:2: /usr/include/c++/10/fstream:1285:5: note: candidate: 'template<class _CharT, class _Traits> void std::swap(std::basic_fstream<_CharT, _Traits>&, std::basic_fstream<_CharT, _Traits>&)' 1285 | swap(basic_fstream<_CharT, _Traits>& __x, | ^~~~ /usr/include/c++/10/fstream:1285:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::basic_fstream<_CharT, _Traits>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/tuple:39, from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from doll.cpp:2: /usr/include/c++/10/array:321:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> void std::swap(std::array<_Tp, _Nm>&, std::array<_Tp, _Nm>&)' 321 | swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) | ^~~~ /usr/include/c++/10/array:321:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::array<_Tp, _Nm>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/functional:54, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from doll.cpp:2: /usr/include/c++/10/tuple:1629:5: note: candidate: 'template<class ... _Elements> void std::swap(std::tuple<_Tps ...>&, std::tuple<_Tps ...>&)' 1629 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/10/tuple:1629:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::tuple<_Tps ...>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/functional:59, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71, from doll.cpp:2: /usr/include/c++/10/bits/std_function.h:720:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(std::function<_Res(_ArgTypes ...)>&, std::function<_Res(_ArgTypes ...)>&)' 720 | swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept | ^~~~ /usr/include/c++/10/bits/std_function.h:720:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::function<_Res(_ArgTypes ...)>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from doll.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:738:5: note: candidate: 'template<class _Tp, class _Dp> void std::swap(std::unique_ptr<_Tp, _Dp>&, std::unique_ptr<_Tp, _Dp>&)' 738 | swap(unique_ptr<_Tp, _Dp>& __x, | ^~~~ /usr/include/c++/10/bits/unique_ptr.h:738:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/list:63, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:79, from doll.cpp:2: /usr/include/c++/10/bits/stl_list.h:2082:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(std::__cxx11::list<_Tp, _Alloc>&, std::__cxx11::list<_Tp, _Alloc>&)' 2082 | swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) | ^~~~ /usr/include/c++/10/bits/stl_list.h:2082:5: note: template argument deduction/substitution failed: doll.cpp:48:18: note: mismatched types 'std::__cxx11::list<_Tp, _Alloc>' and 'int' 48 | swap(tmp, g[i]); | ^ In file included from /usr/include/c++/10/map:60, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81, from doll.cpp:2: /usr/include/c++/10/bits/stl_tree.h:1655:5: note: candidate: 'template<class _Key, class _Val, class _KeyOfValue, class