# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
979660 | 2024-05-11T09:35:28 Z | canadavid1 | A Plus B (IOI23_aplusb) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
#include "aplusb.h" #include <set> #include <utility> std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; std::set<std::pair<int,int>,decltype(cmp)> q(cmp); std::vector<int> out; q.emplace(0,0); while(out.size()<N) { auto[a,b] = *out.begin(); out.push(A[a]+B[b]); out.erase(out.begin()); if(a+1<N) out.emplace(a+1,b); if(b+1<N) out.emplace(a,b+1); } return out; }
Compilation message
aplusb.cpp: In lambda function: aplusb.cpp:5:40: error: 'A' is not captured 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:5:16: note: the lambda has no capture-default 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:4:56: note: 'std::vector<int> A' declared here 4 | std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { | ~~~~~~~~~~~~~~~~~^ aplusb.cpp:5:51: error: 'B' is not captured 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:5:16: note: the lambda has no capture-default 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:4:76: note: 'std::vector<int> B' declared here 4 | std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { | ~~~~~~~~~~~~~~~~~^ aplusb.cpp:5:63: error: 'A' is not captured 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:5:16: note: the lambda has no capture-default 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:4:56: note: 'std::vector<int> A' declared here 4 | std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { | ~~~~~~~~~~~~~~~~~^ aplusb.cpp:5:74: error: 'B' is not captured 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:5:16: note: the lambda has no capture-default 5 | auto cmp = [](auto a,auto b){return A[a.first]+B[a.second]<A[b.first]+B[b.second];}; | ^ aplusb.cpp:4:76: note: 'std::vector<int> B' declared here 4 | std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { | ~~~~~~~~~~~~~~~~~^ aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)': aplusb.cpp:9:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 9 | while(out.size()<N) | ~~~~~~~~~~^~ aplusb.cpp:11:11: error: cannot decompose non-array non-class type 'int' 11 | auto[a,b] = *out.begin(); | ^~~~~ aplusb.cpp:12:11: error: 'class std::vector<int>' has no member named 'push' 12 | out.push(A[a]+B[b]); | ^~~~ In file included from /usr/include/c++/10/set:60, from aplusb.cpp:2: /usr/include/c++/10/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::pair<int, int>]': /usr/include/c++/10/bits/stl_tree.h:2419:19: required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {int, int}; _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >]' /usr/include/c++/10/bits/stl_set.h:463:33: required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {int, int}; _Key = std::pair<int, int>; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::const_iterator]' aplusb.cpp:8:17: required from here /usr/include/c++/10/bits/stl_tree.h:2101:35: error: void value not ignored as it ought to be 2101 | __comp = _M_impl._M_key_compare(__k, _S_key(__x)); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/stl_tree.h:2112:33: error: could not convert '((std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >*)this)->std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_M_impl.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_Rb_tree_impl<smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, false>::<anonymous>.std::_Rb_tree_key_compare<smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)> >::_M_key_compare.smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>((* & std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_S_key(((std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_Const_Base_ptr)__j.std::_Rb_tree_iterator<std::pair<int, int> >::_M_node))), (* & __k))' from 'void' to 'bool' 2112 | if (_M_impl._M_key_compare(_S_key(__j._M_node), __k)) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void /usr/include/c++/10/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type) [with _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::iterator; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Base_ptr = std::_Rb_tree_node_base*; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<int, int> >*]': /usr/include/c++/10/bits/stl_tree.h:2421:20: required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {int, int}; _Key = std::pair<int, int>; _Val = std::pair<int, int>; _KeyOfValue = std::_Identity<std::pair<int, int> >; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >]' /usr/include/c++/10/bits/stl_set.h:463:33: required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {int, int}; _Key = std::pair<int, int>; _Compare = smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>; _Alloc = std::allocator<std::pair<int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::const_iterator]' aplusb.cpp:8:17: required from here /usr/include/c++/10/bits/stl_tree.h:2364:33: error: could not convert '((std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >*)this)->std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_M_impl.std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_Rb_tree_impl<smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, false>::<anonymous>.std::_Rb_tree_key_compare<smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)> >::_M_key_compare.smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>((* & std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_S_key(((std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_Const_Link_type)__z))), (* & std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_S_key(((std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, smallest_sums(int, std::vector<int>, std::vector<int>)::<lambda(auto:1, auto:2)>, std::allocator<std::pair<int, int> > >::_Const_Base_ptr)__p))))' from 'void' to 'bool' 2364 | || _M_impl._M_key_compare(_S_key(__z), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ 2365 | _S_key(__p))); | ~~~~~~~~~~~~