Submission #463826

# Submission time Handle Problem Language Result Execution time Memory
463826 2021-08-11T20:58:43 Z dutch Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#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 <bits/stdc++.h>
#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:6:2: error: 'fill' was not declared in this scope; did you mean 'std::fill'?
    6 |  fill(last, last+N, N);
      |  ^~~~
      |  std::fill
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from advisor.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note: 'std::fill' declared here
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
advisor.cpp:14:2: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   14 |  priority_queue<array<int, 2>> q;
      |  ^~~~~~~~~~~~~~
      |  std::priority_queue
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:456:11: note: 'std::priority_queue' declared here
  456 |     class priority_queue
      |           ^~~~~~~~~~~~~~
advisor.cpp:14:17: error: 'array' was not declared in this scope; did you mean 'std::array'?
   14 |  priority_queue<array<int, 2>> q;
      |                 ^~~~~
      |                 std::array
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from advisor.cpp:1:
/usr/include/c++/10/array:94:12: note: 'std::array' declared here
   94 |     struct array
      |            ^~~~~
advisor.cpp:14:23: error: expected primary-expression before 'int'
   14 |  priority_queue<array<int, 2>> q;
      |                       ^~~
advisor.cpp:17:13: error: 'q' was not declared in this scope
   17 |   if(i < K) q.push({last[i], i});
      |             ^
advisor.cpp:23:14: error: 'q' was not declared in this scope
   23 |    while(!on[q.top()[1]]) q.pop();
      |              ^
advisor.cpp:24:12: error: 'q' was not declared in this scope
   24 |    int j = q.top()[1]; q.pop();
      |            ^
advisor.cpp:27:3: error: 'q' was not declared in this scope
   27 |   q.push({next[C[i]], C[i]});
      |   ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:5:2: error: 'vector' was not declared in this scope
    5 |  vector<int> s;
      |  ^~~~~~
assistant.cpp:5:2: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from assistant.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from assistant.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
assistant.cpp:5:9: error: expected primary-expression before 'int'
    5 |  vector<int> s;
      |         ^~~
assistant.cpp:9:12: error: 's' was not declared in this scope
    9 |   if(A[i]) s.push_back(i);
      |            ^
assistant.cpp:15:17: error: 's' was not declared in this scope
   15 |    PutBack(back(s));
      |                 ^
assistant.cpp:15:12: error: 'back' was not declared in this scope
   15 |    PutBack(back(s));
      |            ^~~~
assistant.cpp:19:14: error: 's' was not declared in this scope
   19 |   if(A[K+i]) s.push_back(j);
      |              ^