Submission #463825

# Submission time Handle Problem Language Result Execution time Memory
463825 2021-08-11T20:58:04 Z dutch Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M){
	int next[N], last[N];
	fill(last, last+N, N);
	bool on[N], r[N+K] = {};

	for(int i=N; --i>=0; ){
		next[C[i]] = last[C[i]];
		last[C[i]] = i;
		on[i] = i < K;
	}
	priority_queue<array<int, 2>> q;

	for(int i=0; i<N; ++i){
		if(i < K) q.push({last[i], i});
		last[i] = i < K ? i : -1;
	}

	for(int i=0; i<N; ++i){
		if(!on[C[i]]){
			while(!on[q.top()[1]]) q.pop();
			int j = q.top()[1]; q.pop();
			r[K+last[j]] = !(on[j] = 0);
		}
		q.push({next[C[i]], C[i]});
		on[C[i]] = 1;
		last[C[i]] = K + i;
	}

	for(int i=0; i<N+K; ++i) WriteAdvice(r[i]);
}
#include "assistant.h"

void Assist(unsigned char *A, int N, int K, int R){
	vector<int> s;
	bool on[N] = {};
	for(int i=0; i<K; ++i){
		on[i] = 1;
		if(A[i]) s.push_back(i);
	}

	for(int i=0; i<N; ++i){
		int j = GetRequest();
		if(!on[j]){
			PutBack(back(s));
			s.pop_back();
			on[j] = 1;
		}
		if(A[K+i]) s.push_back(j);
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:5:2: error: 'fill' was not declared in this scope
    5 |  fill(last, last+N, N);
      |  ^~~~
advisor.cpp:13:2: error: 'priority_queue' was not declared in this scope
   13 |  priority_queue<array<int, 2>> q;
      |  ^~~~~~~~~~~~~~
advisor.cpp:13:17: error: 'array' was not declared in this scope
   13 |  priority_queue<array<int, 2>> q;
      |                 ^~~~~
advisor.cpp:13:23: error: expected primary-expression before 'int'
   13 |  priority_queue<array<int, 2>> q;
      |                       ^~~
advisor.cpp:16:13: error: 'q' was not declared in this scope
   16 |   if(i < K) q.push({last[i], i});
      |             ^
advisor.cpp:22:14: error: 'q' was not declared in this scope
   22 |    while(!on[q.top()[1]]) q.pop();
      |              ^
advisor.cpp:23:12: error: 'q' was not declared in this scope
   23 |    int j = q.top()[1]; q.pop();
      |            ^
advisor.cpp:26:3: error: 'q' was not declared in this scope
   26 |   q.push({next[C[i]], C[i]});
      |   ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:4:2: error: 'vector' was not declared in this scope
    4 |  vector<int> s;
      |  ^~~~~~
assistant.cpp:4:9: error: expected primary-expression before 'int'
    4 |  vector<int> s;
      |         ^~~
assistant.cpp:8:12: error: 's' was not declared in this scope
    8 |   if(A[i]) s.push_back(i);
      |            ^
assistant.cpp:14:17: error: 's' was not declared in this scope
   14 |    PutBack(back(s));
      |                 ^
assistant.cpp:14:12: error: 'back' was not declared in this scope
   14 |    PutBack(back(s));
      |            ^~~~
assistant.cpp:18:14: error: 's' was not declared in this scope
   18 |   if(A[K+i]) s.push_back(j);
      |              ^