Submission #366197

#TimeUsernameProblemLanguageResultExecution timeMemory
366197iliccmarkoDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define input(n, v) {for(int i = 0;i<n;i++) cin>>v[i];}
#define output(n, v) {for(int i = 0;i<n;i++) cout<<v[i]<<" "; cout<<endl;}
#define single_case solve();
#define line cout<<"------------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); }
const int N = 2e5 + 5;
pair<int, int> a[N];
set<pair<int, int> > s;

vector<int> find_subset(int l, int u, vector<int> w)
{
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<int> res;
    int n = len(w);
    for(int i = 0;i<n;i++)
    {
        a[i].first = w[i];
        a[i].second = i;
    }
    sort(a, a+n);
    ll sum = 0;
    for(int i = 0;i<n;i++)
    {
        sum += (ll)a[i].first;
        if(sum>(ll)u)
        {
            sum -= (ll)a[i].first;
            break;
        }
        pq.push(a[i]);
        if(sum<=u&&sum>=l)
        {
            while(len(pq))
            {
                auto x = pq.top();
                res.pb(x.second);
                pq.pop();
            }
            return res;
        }
    }
    int vel = len(pq);
    if(vel==n||!vel) return res;
    for(int i = vel;i<n;i++)
    {
        s.insert(a[i]);
    }
    for(int i = vel;i<n;i++)
    {
        int ind = pq.top().second;
        sum -= pq.top().first;
        s.insert(pq.top());
        pq.pop();
        sum += (ll)(a[i].first);
        pq.push(a[i]);
        s.erase(a[i]);
            ll raz = (ll)u - sum;
            auto x = make_pair((int)raz, -1);
            auto xx = s.upper_bound(all(s), x);
            if(xx!=s.begin())
            {
                xx--;
                pq.push(make_pair(xx->first, xx->second));
                sum += xx->first;
                s.erase(xx);
            }
        if(sum<=u&&sum>=l)
        {
            while(len(pq))
            {
                res.pb(pq.top().second);
                pq.pop();
            }
            return res;
        }
    }
    vector<int> ans;
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:69:46: error: no matching function for call to 'std::set<std::pair<int, int> >::upper_bound(std::set<std::pair<int, int> >::iterator, std::set<std::pair<int, int> >::iterator, std::pair<int, int>&)'
   69 |             auto xx = s.upper_bound(all(s), x);
      |                                              ^
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_set.h:859:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::upper_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>]'
  859 |       upper_bound(const key_type& __x)
      |       ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:859:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/9/bits/stl_set.h:863:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::upper_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>]'
  863 |       upper_bound(const key_type& __x) const
      |       ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:863:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/9/bits/stl_set.h:869: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_upper_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::upper_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> >]'
  869 |  upper_bound(const _Kt& __x)
      |  ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:869:2: note:   template argument deduction/substitution failed:
molecules.cpp:69:46: note:   candidate expects 1 argument, 3 provided
   69 |             auto xx = s.upper_bound(all(s), x);
      |                                              ^
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_set.h:875:2: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_upper_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::upper_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> >]'
  875 |  upper_bound(const _Kt& __x) const
      |  ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_set.h:875:2: note:   template argument deduction/substitution failed:
molecules.cpp:69:46: note:   candidate expects 1 argument, 3 provided
   69 |             auto xx = s.upper_bound(all(s), x);
      |                                              ^
molecules.cpp:60:13: warning: unused variable 'ind' [-Wunused-variable]
   60 |         int ind = pq.top().second;
      |             ^~~