Submission #804400

# Submission time Handle Problem Language Result Execution time Memory
804400 2023-08-03T08:32:13 Z Dan4Life Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

void ComputeAdvice(int *C, int N, int K, int M) {
	for(int i = 0; i < N; i++)
		for(int j = 0; j < 20; j++)
			WriteAdvice((C[i]>>j)&1);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
 
void Assist(unsigned char *A, int N, int K, int R) {
 
  int C[N+1]; vector<int> v[N+1];
  for(int i = 0; i < N; i++) C[i]=0;
  for(int i = 0; i < R; i++)
	  C[i/20] |= (1<<(i%20))*A[i];
  set<int> S; set<pair<int,int>> SS;
  for(int i = 0; i < N; i++) v[C[i]].push_back(i);
  for(int i = 0; i < N; i++) v[i].push_back(N);
  for(int i = 0; i < K; i++){
	  int nx = *upper_bound(begin(v[i]),end(v[i]),-1);
	  S.insert(i); SS.insert({nx,i});
  }
  for(int i = 0; i < N; i++) {
    int req = GetRequest();
    if(S.count(req)) continue;
    int getCol = (--end(SS))->second;
    S.erase(getCol); S.insert(req); PutBack(getCol);
    int nx = *upper_bound(begin(v[req]),end(v[req]),i);
    S.erase(--end(SS)); SS.insert({nx,req});
  }
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:24:22: error: no matching function for call to 'std::set<int>::erase(std::_Rb_tree_const_iterator<std::pair<int, int> >::_Self&)'
   24 |     S.erase(--end(SS)); SS.insert({nx,req});
      |                      ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from assistant.cpp:2:
/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 = 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; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<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 '_Rb_tree_const_iterator<std::pair<int, int>>' to '_Rb_tree_const_iterator<int>'
  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 = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = 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 'std::_Rb_tree_const_iterator<std::pair<int, int> >::_Self' to 'const key_type&' {aka 'const 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 = 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; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<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