Submission #761669

# Submission time Handle Problem Language Result Execution time Memory
761669 2023-06-20T07:01:45 Z SanguineChameleon Last supper (IOI12_supper) C++17
0 / 100
333 ms 24064 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e5 + 20;
vector<int> pos[maxN];

void ComputeAdvice(int *C, int N, int K, int M) {
	int L = 1;
	while ((1 << L) < K) {
		L++;
	}
	for (int i = N - 1; i >= 0; i--) {
		pos[C[i]].push_back(i);
	}
	map<int, int> cur;
	set<pair<int, int>> S;
	for (int i = 0; i < K; i++) {
		S.emplace(pos[i].empty() ? N : 0, i);
		cur[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int x = -1;
		auto it = S.find(make_pair(C[i], 0));
		if (it != S.end()) {
			x = cur[C[i]];
			cur[C[i]] = -1;
			S.erase(it);
		}
		else {
			x = cur[prev(S.end())->second];
			cur[prev(S.end())->second] = -1;
			for (int j = 0; j < L; j++) {
				WriteAdvice((x >> j) & 1);
			}
			S.erase(prev(S.end()));
		}
		cur[C[i]] = x;
		pos[C[i]].pop_back();
		S.emplace(pos[C[i]].empty() ? N : 0, C[i]);
	}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

const int maxK = 1e5 + 20;
int colors[maxK];

void Assist(unsigned char *A, int N, int K, int R) {
	int L = 1;
	while ((1 << L) < K) {
		L++;
	}
	set<int> S;
	for (int i = 0; i < K; i++) {
		colors[i] = i;
		S.insert(i);
	}
	int pt = 0;
	for (int i = 0; i < N; i++) {
		int C = GetRequest();
		if (S.find(C) != S.end()) {
			continue;
		}
		int pos = 0;
		for (int j = 0; j < L; j++) {
			pos |= (A[pt + j] << j);
		}
		pt += L;
		PutBack(colors[pos]);
		S.erase(colors[pos]);
		S.insert(C);
		colors[pos] = C;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2956 KB Output is correct
2 Incorrect 1 ms 2948 KB Error - Putting back a color that is not on the scaffold
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 4492 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 17664 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3084 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 306 ms 20752 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 333 ms 21032 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 318 ms 21268 KB Output isn't correct - not an optimal way
4 Incorrect 306 ms 21176 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 304 ms 21300 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 296 ms 21188 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 318 ms 21168 KB Output isn't correct - not an optimal way
8 Incorrect 323 ms 21200 KB Output isn't correct - not an optimal way
9 Incorrect 301 ms 21100 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 319 ms 24064 KB Output isn't correct - not an optimal way