Submission #402453

#TimeUsernameProblemLanguageResultExecution timeMemory
402453teehandsomeCircle selection (APIO18_circle_selection)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define INF 1e9+7 #define all(x) x.begin(),x.end() using namespace std; using namespace __gnu_pbds; using ll=long long; using pii=pair<int,int>; using ppi=pair<int,pii>; using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>; template<typename T> void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";} void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";} template<typename T> void _print(T x) {cerr<<x;} void dbg() {cerr<<endl;} template<typename Head,typename... Tail> void dbg(Head H,Tail... T) { _print(H); if(sizeof...(T)) cerr<<","; else cerr<<"\"]"; dbg(T...); } #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__) //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); struct dt { ll l,r; int idx; bool intersect(const dt &rr) { if(rr.l>=l and rr.l<=r) return true; if(rr.r>=l and rr.r<=r) return true; return false; } }; struct cmpL { bool operator()(const dt &l,const dt &r) { if(l.l==r.l) return l.r>r.r; return l.l<r.l; } }; struct cmpR { bool operator()(const dt &l,const dt &r) { return l.r<r.r; } }; int main () { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; vector<dt> a(n); set<dt,cmpL> sL; set<dt,cmpR> sR; for(int i=0;i<n;i++) { int x,y,r; cin>>x>>y>>r; a[i]={x-r,x+r,i}; sL.insert(a[i]); sR.insert(a[i]); } sort(all(a),[&](const dt &l,const dt &r) { if((l.r-l.l)==(r.r-r.l)) return l.l<r.l; return (l.r-l.l)>(r.r-r.l); }); vector<int> ans(n,-1); for(int i=0;i<n;i++) { int u=a[i].idx; if(ans[u]!=-1) continue; auto p=sL.lower_bound(a[i]); vector<dt> to_del; while(p!=sL.end()) { int v=p->idx; if(ans[v]!=-1) break; if(!a[i].intersect(*p)) break; to_del.push_back(*p); // sL.erase(p); sR.erase(p); ans[v]=u; p++; } for(auto e:to_del) sL.erase(e),sR.erase(e); vector<dt> to_del2; auto p2=sR.upper_bound(a[i]); if(p2!=sR.begin()) --p2; while(p2!=sR.begin()) { int v=p2->idx; if(ans[v]!=-1) break; if(!a[i].intersect(*p2)) break; to_del2.push_back(*p2); // sL.erase(p2); sR.erase(p2); ans[v]=u; p2--; } for(auto e:to_del2) sL.erase(e),sR.erase(e); } for(int i=0;i<n;i++) cout<<ans[i]+1<<" "; cout<<endl; }

Compilation message (stderr)

In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from circle_selection.cpp:1:
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpL; _Alloc = std::allocator<dt>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<dt>*]':
/usr/include/c++/10/bits/stl_tree.h:2101:47:   required from '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 = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpL; _Alloc = std::allocator<dt>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = dt]'
/usr/include/c++/10/bits/stl_tree.h:2154:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const dt&; _Key = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpL; _Alloc = std::allocator<dt>]'
/usr/include/c++/10/bits/stl_set.h:512:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = dt; _Compare = cmpL; _Alloc = std::allocator<dt>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<dt, dt, std::_Identity<dt>, cmpL, std::allocator<dt> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = dt]'
circle_selection.cpp:62:23:   required from here
/usr/include/c++/10/bits/stl_tree.h:780:8: error: static assertion failed: comparison object must be invocable as const
  780 |        is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpR; _Alloc = std::allocator<dt>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<dt>*]':
/usr/include/c++/10/bits/stl_tree.h:2101:47:   required from '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 = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpR; _Alloc = std::allocator<dt>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = dt]'
/usr/include/c++/10/bits/stl_tree.h:2154:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const dt&; _Key = dt; _Val = dt; _KeyOfValue = std::_Identity<dt>; _Compare = cmpR; _Alloc = std::allocator<dt>]'
/usr/include/c++/10/bits/stl_set.h:512:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = dt; _Compare = cmpR; _Alloc = std::allocator<dt>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<dt, dt, std::_Identity<dt>, cmpR, std::allocator<dt> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = dt]'
circle_selection.cpp:63:23:   required from here
/usr/include/c++/10/bits/stl_tree.h:780:8: error: static assertion failed: comparison object must be invocable as const