Submission #926851

# Submission time Handle Problem Language Result Execution time Memory
926851 2024-02-14T00:25:56 Z daoquanglinh2007 Last supper (IOI12_supper) C++17
0 / 100
50 ms 7680 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair <int, int>
#define fi first
#define se second
#define mp make_pair

const int NM = 2e5, inf = 1e9+7;

namespace advisor{
	int col[NM+5], lst[NM+5], nxt[NM+5];
	bool ok[NM+5];
	priority_queue <pii> q;
	bool ans[NM+5];
	void solve(int *C, int N, int K, int M){
		assert(M > 0);
		for (int i = 0; i < K; i++) col[i] = i;
		for (int i = 0; i < N; i++) col[K+i] = C[i];
		for (int i = 0; i < N; i++) lst[i] = -1;
		for (int i = N+K-1; i >= 0; i--){
			if (lst[col[i]] == -1) nxt[i] = +inf;
			else nxt[i] = lst[col[i]];
			lst[col[i]] = i;
		}
		for (int i = 0; i < K; i++) q.push(mp(+inf+1, -1));
		for (int i = 0; i < N+K; i++){
			if (ok[col[i]]) continue;
			pii P = q.top(); q.pop();
			if (P.se != -1){
				ans[P.se] = 1;
				ok[col[P.se]] = 0;
			}
			q.push(mp(nxt[i], i));
			ok[col[i]] = 1;
		}
		for (int i = 0; i < N+K; i++) WriteAdvice(ans[i]);
	}
}

void ComputeAdvice(int *C, int N, int K, int M){
	advisor::solve(C, N, K, M);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair <int, int>
#define fi first
#define se second
#define mp make_pair

const int NM = 2e5, inf = 1e9+7;

namespace assistant{
	queue <int> q;
	bool ok[NM+5];
	void solve(unsigned char *A, int N, int K, int R){
		assert(R == N+K);
		for (int i = 0; i < K; i++){
			ok[i] = 1;
			if (A[i]) q.push(i);
		}
		for (int i = 0; i < N; i++){
			int x = GetRequest();
			if (!ok[x]){
				int y = q.front(); q.pop();
				PutBack(y);
				ok[y] = 0;
				ok[x] = 1;
			}
			if (A[K+i]) q.push(x);
		}
	}
}

void Assist(unsigned char *A, int N, int K, int R){
	assistant::solve(A, N, K, R);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2832 KB Output is correct
2 Incorrect 1 ms 2856 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 5 ms 3176 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 6092 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2872 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 6384 KB Output isn't correct - not an optimal way
2 Incorrect 49 ms 6648 KB Output isn't correct - not an optimal way
3 Incorrect 50 ms 7244 KB Output isn't correct - not an optimal way
4 Incorrect 45 ms 6384 KB Output isn't correct - not an optimal way
5 Incorrect 45 ms 6276 KB Output isn't correct - not an optimal way
6 Incorrect 44 ms 6724 KB Output isn't correct - not an optimal way
7 Incorrect 46 ms 6332 KB Output isn't correct - not an optimal way
8 Incorrect 44 ms 6376 KB Output isn't correct - not an optimal way
9 Incorrect 45 ms 6376 KB Output isn't correct - not an optimal way
10 Correct 44 ms 7680 KB Output is correct - 125000 bits used