Submission #761820

# Submission time Handle Problem Language Result Execution time Memory
761820 2023-06-20T10:10:21 Z Sohsoh84 Last supper (IOI12_supper) C++17
40 / 100
312 ms 39256 KB
#include "advisor.h"
#include <bits/stdc++.h>

// TODO: check k = 1

using namespace std;

#define X		first
#define	Y		second
#define all(x)	(x).begin(), (x).end()

const int MAXN = 1e6 + 10;

typedef pair<int, int> pll;

int n, k, m;
vector<int> vec[MAXN];

inline int wtf(int k) {
	int ans = 1, res = 0;
	while (ans < k)
		ans *= 2, res++;

	return res;
}

inline void put(int x) {
	for (int i = m - 1; i >= 0; i--)
		WriteAdvice(x >> i & 1);
}

inline int get(int c, int i) {
	return *lower_bound(all(vec[c]), i);
}

void ComputeAdvice(int *C, int N, int K, int M) {
	n = N, k = K;
	m = wtf(n);

	for (int i = 0; i < n; i++)
		vec[C[i]].push_back(i);

	for (int i = 0; i < n; i++)
		vec[i].push_back(n);

	set<pll> st;
	for (int i = 0; i < k; i++)
		st.insert(pll(get(i, 0), i));

	for (int i = 0; i < n; i++) {
		int c = C[i];
		if (st.find(pll(get(c, i), c)) != st.end()) {
			st.erase(pll(get(c, i), c));
		} else {
			put(st.rbegin() -> Y);
			st.erase(prev(st.end()));
		}

		st.insert(pll(get(c, i + 1), c));
	}
}
#include "assistant.h"
#include <bits/stdc++.h>

#define X		first
#define	Y		second

using namespace std;

typedef pair<int, int> pll;

inline int wtf(int k) {
	int ans = 1, res = 0;
	while (ans < k)
		ans *= 2, res++;

	return res;
}

void Assist(unsigned char *A, int N, int K, int R) {
  	int n = N, k = K, m = wtf(n);


	set<int> st;
	for (int i = 0; i < k; i++)
		st.insert(i);

	int ind = 0;
	for (int i = 0; i < n; i++) {
		int c = GetRequest();
		if (st.find(c) != st.end()) continue;

		int x = 0;
		for (int i = m - 1; i >= 0; i--) {
			x <<= 1;
			x |= A[ind];
			ind++;
		}

		PutBack(x);
		st.erase(x);
		st.insert(c);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 24108 KB Output is correct
2 Correct 12 ms 24108 KB Output is correct
3 Correct 11 ms 24336 KB Output is correct
4 Correct 16 ms 24432 KB Output is correct
5 Correct 21 ms 24712 KB Output is correct
6 Correct 23 ms 24756 KB Output is correct
7 Correct 19 ms 24540 KB Output is correct
8 Correct 21 ms 24736 KB Output is correct
9 Correct 23 ms 24748 KB Output is correct
10 Correct 19 ms 24676 KB Output is correct
11 Correct 19 ms 24612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 25272 KB Output is correct
2 Correct 94 ms 29176 KB Output is correct
3 Correct 238 ms 38504 KB Output is correct
4 Correct 287 ms 39216 KB Output is correct
5 Correct 285 ms 38696 KB Output is correct
6 Correct 253 ms 37064 KB Output is correct
7 Correct 230 ms 36628 KB Output is correct
8 Correct 219 ms 36932 KB Output is correct
9 Correct 312 ms 39176 KB Output is correct
10 Correct 202 ms 36644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 33836 KB Output is correct
2 Correct 223 ms 36536 KB Output is correct
3 Correct 205 ms 36372 KB Output is correct
4 Correct 196 ms 36172 KB Output is correct
5 Correct 170 ms 34412 KB Output is correct
6 Correct 228 ms 36332 KB Output is correct
7 Correct 239 ms 36204 KB Output is correct
8 Correct 259 ms 39256 KB Output is correct
9 Correct 145 ms 34576 KB Output is correct
10 Correct 214 ms 36548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 24240 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 212 ms 36300 KB Output is partially correct - 875347 bits used
2 Correct 249 ms 36380 KB Output is partially correct - 841041 bits used
3 Correct 250 ms 36440 KB Output is partially correct - 807466 bits used
4 Correct 223 ms 36344 KB Output is partially correct - 806939 bits used
5 Correct 210 ms 36344 KB Output is partially correct - 805358 bits used
6 Correct 234 ms 36452 KB Output is partially correct - 807109 bits used
7 Correct 243 ms 36224 KB Output is partially correct - 805902 bits used
8 Correct 226 ms 36432 KB Output is partially correct - 808452 bits used
9 Correct 230 ms 36308 KB Output is partially correct - 807874 bits used
10 Correct 268 ms 39128 KB Output is partially correct - 1266636 bits used