Submission #260156

#TimeUsernameProblemLanguageResultExecution timeMemory
260156sckmdBaloni (COCI15_baloni)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 1000005 typedef pair<int,int> pii; set <pii> st; void go(int height,int prev) { if(st.lower_bound(height,prev)==st.end())return ; auto it = st.lower_bound({height,prev}); pii x = *it; if(x.first != height)return ; if(x.second < prev)return ; st.erase(it); go(height-1,x.second); } int solve() { int ans = 0; for(int height = MAXN-1; height > 0;) { if(st.lower_bound({height,-1})==st.end()){height--;continue;} /*auto it = st.lower_bound({height,-1}); pii x = *it; if(x.first != height){height--;continue;}*/ go(height,-1); ans++; } return ans; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for(int i = 1; i <= n; i++) { int h; cin >> h; st.insert({h,i}); } cout << solve(); return 0; }

Compilation message (stderr)

baloni.cpp: In function 'void go(int, int)':
baloni.cpp:10:32: error: no matching function for call to 'std::set<std::pair<int, int> >::lower_bound(int&, int&)'
   if(st.lower_bound(height,prev)==st.end())return ;
                                ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from baloni.cpp:1:
/usr/include/c++/7/bits/stl_set.h:800:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::lower_bound(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>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x)
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:800:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_set.h:804:7: note: candidate: std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::lower_bound(const key_type&) const [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>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x) const
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:804:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_set.h:810:2: note: candidate: template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  lower_bound(const _Kt& __x)
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:810:2: note:   template argument deduction/substitution failed:
baloni.cpp:10:32: note:   candidate expects 1 argument, 2 provided
   if(st.lower_bound(height,prev)==st.end())return ;
                                ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from baloni.cpp:1:
/usr/include/c++/7/bits/stl_set.h:816:2: note: candidate: template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::const_iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  lower_bound(const _Kt& __x) const
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_set.h:816:2: note:   template argument deduction/substitution failed:
baloni.cpp:10:32: note:   candidate expects 1 argument, 2 provided
   if(st.lower_bound(height,prev)==st.end())return ;
                                ^