Submission #430175

#TimeUsernameProblemLanguageResultExecution timeMemory
430175MounirLast supper (IOI12_supper)C++14
0 / 100
2586 ms11060 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);
	}

	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;
				int present = in;
				int ind = iReq + 1;
				while (ind < N && C[ind] != present)
					++ind;
				if (ind > procUtil){
					procUtil = ind;
					color = present;
				}
			}

			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...