제출 #385694

#제출 시각아이디문제언어결과실행 시간메모리
385694taulantFinding Routers (IOI20_routers)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int use_detector(int); vector<int> find_routers(int l, int n, int q){ set<pii> s; s.insert({0,0}); s.insert({n,l}); vector<int> ret(n); // ret[0] = 0 for(int i = 1; i < n; ++i){ int lo = ret[i-1], hi = l; auto ir = s.lower_bound(i, 0); auto il = ir - 1; lo = max(lo, il -> second), hi = min(hi, il -> first); while(lo < hi){ int mid = (lo + hi + 1) / 2; int x = use_detector(mid); s.insert({x, mid}); if(x < i) lo = mid; else hi = mid - 1; } ret[i] = lo + lo - ret[i-1]; } return ret; }

컴파일 시 표준 에러 (stderr) 메시지

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:14:31: error: no matching function for call to 'std::set<std::pair<int, int> >::lower_bound(int&, int)'
   14 |   auto ir = s.lower_bound(i, 0);
      |                               ^
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from routers.cpp:1:
/usr/include/c++/9/bits/stl_set.h:829: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>]'
  829 |       lower_bound(const key_type& __x)
      |       ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:829:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_set.h:833: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>]'
  833 |       lower_bound(const key_type& __x) const
      |       ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:833:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_set.h:839: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> >]'
  839 |  lower_bound(const _Kt& __x)
      |  ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:839:2: note:   template argument deduction/substitution failed:
routers.cpp:14:31: note:   candidate expects 1 argument, 2 provided
   14 |   auto ir = s.lower_bound(i, 0);
      |                               ^
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from routers.cpp:1:
/usr/include/c++/9/bits/stl_set.h:845: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> >]'
  845 |  lower_bound(const _Kt& __x) const
      |  ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:845:2: note:   template argument deduction/substitution failed:
routers.cpp:14:31: note:   candidate expects 1 argument, 2 provided
   14 |   auto ir = s.lower_bound(i, 0);
      |                               ^