Submission #365334

# Submission time Handle Problem Language Result Execution time Memory
365334 2021-02-11T13:28:05 Z Seanliu Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#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;

const int maxN = 1e5 + 326;

bool cur[maxN];
queue<int> que;

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]) que.push(i);
	}
	for(int i = 0; i < N; i++){
		int r = GetRequest();	
		if(!cur[r]){
			int c = que.front();
			PutBack(c);
			cur[c] = false;
			que.pop();
		}
		cur[r] = true;
	}
}
#include "advisor.h"
#include <iostream>
#include <utility>
#include <cassert>
#include <map>
#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 time == o.time ? col < o.col : time < o.time;
	}
};

const int maxN = 1e5 + 326;
bool has[maxN], advice[maxN << 1];
map<int, Obj> mp;
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;
		mp[furt] = Obj(i - K, i);
	}
	for(int i = 0; i < N; i++){ //thirteen bits lol
		if(has[C[i]]){
			int furt = dq[C[i]].size() ? dq[i].front() : maxN;
			mp.erase(mp.find(furt));
		} else {
			auto it = mp.rbegin();
			advice[it->S.time + K] = 1;
			mp.erase(mp.find(it->F));
			has[it->S.col] = false;
		}
		while(dq[C[i]].size() && dq[C[i]].front() <= i) dq[C[i]].pop_front();
		int furt = dq[C[i]].size() ? dq[i].front() : maxN;
		mp[furt] = Obj(i + K, C[i]);
		has[C[i]] = true;
	}
	for(int i = 0; i < N + K; i++) WriteAdvice(advice[i]);
}

Compilation message

/tmp/cce9xjBI.o: In function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0xaf): undefined reference to `GetRequest()'
advisor.cpp:(.text+0xcb): undefined reference to `PutBack(int)'
/tmp/ccZFyWou.o: In function `main':
advisor_grader.cpp:(.text.startup+0xde): undefined reference to `ComputeAdvice(int*, int, int, int)'
collect2: error: ld returned 1 exit status

/tmp/ccBD57UJ.o: In function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x568): undefined reference to `WriteAdvice(unsigned char)'
/tmp/ccAG5k8s.o: In function `main':
assistant_grader.cpp:(.text.startup+0x23f): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status