Submission #1317882

#TimeUsernameProblemLanguageResultExecution timeMemory
1317882nathako9nStone Arranging 2 (JOI23_ho_t1)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int N = 200005;
struct com{
    bool operator()(const pair<ll,ll>&a,const pair<ll,ll>&b){
        if(a.second==b.second)return a.first<b.first;
        else return a.second<b.second;
    }
};
set<pair<ll,ll>,com>st;
map<int,int>in;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;cin>>n;
    ll x;cin>>x;
    st.insert({x,1});
    in[x]=1;
    for(int i=2;i<=n;i++){
        ll x;cin>>x;

        auto pos=st.find(make_pair(x,in[x]));
        if(pos==st.end()){
            st.insert({x,i});
            in[x]=i;
          //  cout<<"f";
        }
        else{
            while(!st.empty()&&(st.rbegin()->second)>(pos->second))st.erase(prev(st.end()));

        }
//        cout<<i<<endl;
//        for(auto [x,y]:st){
//            cout<<x<<" "<<y<<endl;
//        }
       // cout<<endl<<endl;
    }
    st.insert({-1,n+1});
    int i=1;
    for(auto it=st.begin();it!=prev(st.end());++it){
        while(i<next(it)->second){cout<<it->first<<" ";i++;}
    }
}
/*

6
1
2
1
2
3
2

*/

Compilation message (stderr)

In file included from /usr/include/c++/13/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from Main.cpp:1:
/usr/include/c++/13/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = com; _Alloc = std::allocator<std::pair<long long int, long long int> >; _Const_Link_type = const std::_Rb_tree_node<std::pair<long long int, long long int> >*]':
/usr/include/c++/13/bits/stl_tree.h:2118: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 = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = com; _Alloc = std::allocator<std::pair<long long int, long long int> >; key_type = std::pair<long long int, long long int>]'
/usr/include/c++/13/bits/stl_tree.h:2171: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 = std::pair<long long int, long long int>; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = com; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
/usr/include/c++/13/bits/stl_set.h:523: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(value_type&&) [with _Key = std::pair<long long int, long long int>; _Compare = com; _Alloc = std::allocator<std::pair<long long int, long long int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, com, std::allocator<std::pair<long long int, long long int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::pair<long long int, long long int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::rebind<std::pair<long long int, long long int> >; typename _Alloc::value_type = std::pair<long long int, long long int>; value_type = std::pair<long long int, long long int>]'
Main.cpp:19:14:   required from here
/usr/include/c++/13/bits/stl_tree.h:772:15: error: static assertion failed: comparison object must be invocable as const
  772 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_tree.h:772:15: note: 'std::is_invocable_v<const com&, const std::pair<long long int, long long int>&, const std::pair<long long int, long long int>&>' evaluates to false