Submission #889435

# Submission time Handle Problem Language Result Execution time Memory
889435 2023-12-19T16:41:56 Z codefox Sirni (COCI17_sirni) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<int, int>

int main()
{
    int n;
    cin >> n;
    vector<int> nums(n);
    set<pii> num;
    for(int i = 0; i < n; i++)
    {
        cin >> nums[i];
        num.insert({nums[i], i});
    }
    sort(nums.begin(), nums.end());
    set<int> mult;
    for (int j = nums[0]; j <=1e7; j+=nums[0])
    {
        mult.insert(j);
    }
    ll sol = 0;

    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.push({0,0});
    for(int i = 1; i < n; i++) pq.push({nums[i], nums[i]});
    vector<bool> vis(n, 0);

    while (pq.size())
    {
        int i, d;
        tie(d, i) = pq.top();
        pq.pop();
        if (vis[i]) continue;
        vis[i] = true;
        num.erase(i);
        for (int j = nums[i]; j <=1e7; j+=nums[i])
        {
            auto u = num.lower_bound({j, 0});
            if (u != num.end()) pq.push({(*u).first-j, (*u).second});
        }
        sol+=d;
    }
    cout << sol;

    return 0;
}

Compilation message

sirni.cpp: In function 'int main()':
sirni.cpp:39:20: error: no matching function for call to 'std::set<std::pair<int, int> >::erase(int&)'
   39 |         num.erase(i);
      |                    ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from sirni.cpp:1:
/usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [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<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]'
  654 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:654:28: note:   no known conversion for argument 1 from 'int' to 'std::set<std::pair<int, int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'}
  654 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(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>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  684 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:684:29: note:   no known conversion for argument 1 from 'int' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  684 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [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<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]'
  706 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:706:7: note:   candidate expects 2 arguments, 1 provided