Submission #430183

#TimeUsernameProblemLanguageResultExecution timeMemory
430183MounirLast supper (IOI12_supper)C++14
8 / 100
2596 ms78276 KiB

#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

const int N_BITS = 13;

void ComputeAdvice(int *C, int N, int K, int M) {
	for (int iVal = 0; iVal < N; ++iVal){
		int val = C[iVal];
		for (int i = 0; i < N_BITS; ++i)
			WriteAdvice((val&(1 << i)) > 0);
	}
}



#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

const int N_BITS = 13;

void Assist(unsigned char *A, int N, int K, int R) {
	vector<int> C;
	for (int i  = 0; i < R; i += N_BITS){
		int tot = 0;
		for (int bit = 0; bit < N_BITS; ++bit)
			tot += A[i + bit] * (1 << bit);
		C.push_back(tot);
	}

	queue<int> file[N];
	for (int ind = 0; ind < N; ++ind)
		file[C[ind]].push(ind);

	bool presents[N];
	for (int i = 0; i < N; ++i)
		presents[i] = false;
	for (int i = 0; i < K; ++i)
		presents[i] = true;

	for (int iReq = 0; iReq < N; ++iReq){
		int proc = GetRequest();

		if (!presents[proc]){
			int procUtil = -1, color = -1;
			for (int in = 0; in < N; ++in){
				if (!presents[in]) continue;
				while (!file[in].empty() && file[in].front() < iReq)
					file[in].pop();
				if (file[in].empty()){
					procUtil = 1e9;
					color = in;
				}
				else if (file[in].front() > procUtil){
					procUtil = file[in].front();
					color = in;
				}
			}

			PutBack(color);
			presents[color] = false;
			presents[proc] = true;
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...