# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743447 | 2023-05-17T11:47:13 Z | Mauve | Swapping Cities (APIO20_swap) | C++14 | Compilation error |
0 ms | 0 KB |
#include "swap.h" #include<bits/stdc++.h> #define pb push_back #define ss second #define ff first using namespace std; int l,r,i,j,ii,jj,k,n,m,mx,subtask=1; vector< pair<int,int> > v[100000]; set< pair<int,int> > st; void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) { n=N; m=M; for(i=0;i<M;i++){ v[U[i]].pb({V[i],W[i]}); v[V[i]].pb({U[i],W[i]}); mx=max(mx,W[i]); st.insert({W[i],V[i]}); } for(i=0;i<n;i++) if(v[i].size()>2) subtask=2; } int getMinimumFuelCapacity(int X, int Y) { if(subtask==1){ if(n>m) return -1; else return mx; } if(X==0 || Y==0) return -1; st.erase({v[X].ss,X}); st.erase({v[Y].ss,Y}); mx=max(v[X].ss,v[Y].ss); mx=max(mx,(*st.begin()).ff); st.insert({v[X].ss,X}); st.insert({v[Y].ss,Y}); return mx; }
Compilation message
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)': swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:27:20: note: in expansion of macro 'ss' 27 | st.erase({v[X].ss,X}); | ^~ swap.cpp:27:25: error: no matching function for call to 'std::set<std::pair<int, int> >::erase(<brace-enclosed initializer list>)' 27 | st.erase({v[X].ss,X}); | ^ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from swap.cpp:2: /usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 654 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:654:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} 654 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]' 684 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:684:29: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 684 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 706 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate expects 2 arguments, 1 provided swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:28:20: note: in expansion of macro 'ss' 28 | st.erase({v[Y].ss,Y}); | ^~ swap.cpp:28:25: error: no matching function for call to 'std::set<std::pair<int, int> >::erase(<brace-enclosed initializer list>)' 28 | st.erase({v[Y].ss,Y}); | ^ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from swap.cpp:2: /usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 654 | erase(const_iterator __position) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:654:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} 654 | erase(const_iterator __position) | ~~~~~~~~~~~~~~~^~~~~~~~~~ /usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]' 684 | erase(const key_type& __x) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:684:29: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 684 | erase(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]' 706 | erase(const_iterator __first, const_iterator __last) | ^~~~~ /usr/include/c++/10/bits/stl_set.h:706:7: note: candidate expects 2 arguments, 1 provided swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:29:17: note: in expansion of macro 'ss' 29 | mx=max(v[X].ss,v[Y].ss); | ^~ swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:29:25: note: in expansion of macro 'ss' 29 | mx=max(v[X].ss,v[Y].ss); | ^~ swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:31:21: note: in expansion of macro 'ss' 31 | st.insert({v[X].ss,X}); | ^~ swap.cpp:31:26: error: no matching function for call to 'std::set<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' 31 | st.insert({v[X].ss,X}); | ^ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from swap.cpp:2: /usr/include/c++/10/bits/stl_set.h:509:7: note: candidate: '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>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _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> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 509 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:509:32: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'} 509 | insert(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:518:7: note: candidate: '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>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _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> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 518 | insert(value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:518:27: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 518 | insert(value_type&& __x) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:546:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 546 | insert(const_iterator __position, const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:546:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_set.h:551:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 551 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:551:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_set.h:566:2: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 566 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:566:2: note: template argument deduction/substitution failed: swap.cpp:31:26: note: candidate expects 2 arguments, 1 provided 31 | st.insert({v[X].ss,X}); | ^ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from swap.cpp:2: /usr/include/c++/10/bits/stl_set.h:578:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 578 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:578:43: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >' 578 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ swap.cpp:4:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'second' 4 | #define ss second | ^~~~~~ swap.cpp:32:21: note: in expansion of macro 'ss' 32 | st.insert({v[Y].ss,Y}); | ^~ swap.cpp:32:26: error: no matching function for call to 'std::set<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' 32 | st.insert({v[Y].ss,Y}); | ^ In file included from /usr/include/c++/10/set:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from swap.cpp:2: /usr/include/c++/10/bits/stl_set.h:509:7: note: candidate: '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>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _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> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 509 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:509:32: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'} 509 | insert(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:518:7: note: candidate: '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>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _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> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 518 | insert(value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:518:27: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 518 | insert(value_type&& __x) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_set.h:546:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 546 | insert(const_iterator __position, const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_set.h:546:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_set.h:551:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<in