Submission #365383

# Submission time Handle Problem Language Result Execution time Memory
365383 2021-02-11T14:36:58 Z Seanliu Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <set>
#include <deque>
#define pii pair<int,int>
#define F first
#define S second
using namespace std;

struct Obj{
	int time, col;
	Obj(int time = 0, int col = 0): time(time), col(col){}
	const bool operator<(const Obj &o) const {
		return col == o.col ? time < o.time : col < o.col;
	}
};

const int maxN = 1e5 + 326;
bool has[maxN], advice[maxN << 1];
set <pair<int, Obj>> st;
deque<int> dq[maxN];


void ComputeAdvice(int *C, int N, int K, int M) {
	fill(has, has + K, 1);
	for(int i = 0; i < N; i++){
		dq[C[i]].push_back(i);
	}
	for(int i = 0; i < K; i++){
		int furt = dq[i].size() ? dq[i].front() : maxN;
		st.insert({furt, Obj(i - K, i)});
	}
	//int bc = 0, key;
	//while((1 << bc) < N + 1) bc++;
	for(int i = 0; i < N; i++){ //thirteen bits lol
		//key = -1;
		if(has[C[i]]){
			int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
			st.erase(st.lower_bound({furt, Obj(-maxN, C[i])}));
		} else {
			auto it = --st.end();
			advice[it->S.time + K] = 1;
			st.erase(st.find({it->F, it->S}));
			has[it->S.col] = false;
			key = it->S.col;
		}
		//if(key == -1) key = (1 << bc) - 1;
		while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
		int furt = dq[C[i]].size() ? dq[C[i]].front() : maxN;
		st.insert({furt, Obj(i, C[i])});
		has[C[i]] = true;
		//for(int j = 0; j < bc; j++) WriteAdvice((key >> j) & 1);
	}
	for(int i = 0; i < N + K; i++) WriteAdvice(advice[i]);
}

#include <iostream>
#include <set>
#include <utility>
#include <queue>
#include <cassert>
#define pii pair<int,int>
#define F first
#define S second
#include "assistant.h"
using namespace std;


bool cur[101010], inq[101010];

void Assist(unsigned char *A, int N, int K, int R) {
	//assert(R == N + K);	
	for(int i = 0; i < K; i++){
		cur[i] = true;
		if(A[i]) inq[i] = true;
	}
	//int bc = 0, key;
	//while((1 << bc) < N + 1) bc++;
	for(int i = 0; i < N; i++){
		int r = GetRequest();	
		if(!cur[r]){
			for(int j = 0; j < N; j++){
				if(cur[j] && inq[j]){
					cur[j] = false;
					inq[j] = false;
					PutBack(j);
					break;
				}
			}
		} 
		cur[r] = true;
		if(A[i + K]) inq[r] = true;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:47:4: error: 'key' was not declared in this scope; did you mean 'key_t'?
   47 |    key = it->S.col;
      |    ^~~
      |    key_t