81552024-01-12 14:49:27madvirSzínes szobák (50 pont)cpp17Forditási hiba
#include <iostream>
#include <set>

using namespace std;

int main() {
    int n, k, m, x, lep, el=0;
    cin >> n >> k >> m;
    int c[n+1];
    set<int> szin[k+1];
    
    for(int i=0; i<=n; i++) {
        cin >> x;
        szin[x].insert(i);
    }
    
    for(int i=1; i<=n; i++) {
        cin >> x >> lep;
        if(lep==1) {
            szin[x].erase(*szin[x].begin());
            if(*szin[x].rbegin()+1>n) {
                el++;
                szin[x].erase(*szin[x].rbegin());
            }
            szin[x].insert(*szin[x].rbegin()+1);
        }
        else {
            szin[x].erase(*szin[x].rbegin());
            if(*szin[x].begin-1<=0) {
                el++;
                szin[x].erase(*szin[x].begin());
            }
            szin.insert(*szin[x].begin());
        }
    }
    
    cout << lep;
    
    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:29:25: error: invalid use of member function 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::begin() const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator]' (did you forget the '()' ?)
   29 |             if(*szin[x].begin-1<=0) {
      |                 ~~~~~~~~^~~~~
      |                              ()
main.cpp:33:18: error: request for member 'insert' in 'szin', which is of non-class type 'std::set<int> [(k + 1)]'
   33 |             szin.insert(*szin[x].begin());
      |                  ^~~~~~
Exited with error status 1