Submission #761853

# Submission time Handle Problem Language Result Execution time Memory
761853 2023-06-20T10:30:59 Z SanguineChameleon Last supper (IOI12_supper) C++17
0 / 100
100 ms 12008 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

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

void ComputeAdvice(int *C, int N, int K, int M) {
	for (int i = N - 1; i >= 0; i--) {
		pos[C[i]].push_back(i);
	}
	set<pair<int, int>> S;
	for (int i = 0; i < K; i++) {
		S.emplace(pos[i].empty() ? N : pos[i].back(), i);
	}
	for (int i = 0; i < N; i++) {
		if (S.begin()->first == i) {
			S.erase(S.begin());
		}
		else {
			A[prev(S.end())->second] = 1;
			S.erase(prev(S.end()));
		}
		pos[C[i]].pop_back();
		S.emplace(pos[C[i]].empty() ? N : pos[C[i]].back(), K + i);
	}
	for (int i = 0; i < K + N; i++) {
		WriteAdvice(A[i]);
	}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

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

void Assist(unsigned char *A, int N, int K, int R) {
	set<int> free;
	set<int> S;
	for (int i = 0; i < K; i++) {
		flag[i] = A[i];
		if (A[i] == 1) {
			free.insert(i);
		}
		S.insert(i);
	}
	for (int i = 0; i < N; i++) {
		int X = GetRequest();
		if (S.find(X) == S.end()) {
			int Y = *free.begin();
			PutBack(Y);
			free.erase(Y);
			S.erase(Y);
			S.insert(X);
		}
		if (flag[X] == 0 && A[K + i] == 1) {
			free.insert(X);
		}
		if (flag[X] == 1 && A[K + i] == 0) {
			free.erase(X);
		}
		flag[X] = A[K + i];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2948 KB Output is correct
2 Correct 1 ms 2948 KB Output is correct
3 Correct 3 ms 3088 KB Output is correct
4 Incorrect 3 ms 2964 KB Error - Putting back a color that is not on the scaffold
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 3736 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 Correct 76 ms 9456 KB Output is correct
2 Correct 95 ms 11072 KB Output is correct
3 Correct 97 ms 11236 KB Output is correct
4 Correct 96 ms 11128 KB Output is correct
5 Incorrect 100 ms 10252 KB Error - Putting back a color that is not on the scaffold
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3232 KB Output is correct
2 Correct 5 ms 3372 KB Output is correct
3 Incorrect 4 ms 3244 KB Error - Putting back a color that is not on the scaffold
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 10684 KB Error - Putting back a color that is not on the scaffold
2 Correct 94 ms 11000 KB Output is correct - 122000 bits used
3 Correct 96 ms 11356 KB Output is correct - 125000 bits used
4 Correct 95 ms 11264 KB Output is correct - 125000 bits used
5 Correct 95 ms 11240 KB Output is correct - 125000 bits used
6 Correct 96 ms 11384 KB Output is correct - 125000 bits used
7 Correct 96 ms 11144 KB Output is correct - 124828 bits used
8 Correct 100 ms 11248 KB Output is correct - 124910 bits used
9 Correct 95 ms 11344 KB Output is correct - 125000 bits used
10 Incorrect 88 ms 12008 KB Error - Putting back a color that is not on the scaffold