Submission #1236262

#TimeUsernameProblemLanguageResultExecution timeMemory
1236262kaiboyQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++20
100 / 100
712 ms39604 KiB
// coached by rainboy
int encode(int n, int a, int b) {
	static int *aa = new int[n];
	static bool inited;
	if (!inited) {
		int *kk = new int[1 << 12];
		kk[0] = 0;
		for (int a = 1, i = 0; i < n; i++) {
			while ((kk[a] = kk[a & a - 1] + 1) != 6)
				a++;
			aa[i] = a++;
		}
		delete[] kk;
		inited = true;
	}
	a = aa[a - 1], b = aa[b - 1];
	int h = 0;
	while (!(a >> h & 1) || b >> h & 1)
		h++;
	return h + 1;
}
// coached by rainboy
bool decode(int n, int c, int h) {
	static int *aa = new int[n];
	static bool inited;
	if (!inited) {
		int *kk = new int[1 << 12];
		kk[0] = 0;
		for (int a = 1, i = 0; i < n; i++) {
			while ((kk[a] = kk[a & a - 1] + 1) != 6)
				a++;
			aa[i] = a++;
		}
		delete[] kk;
		inited = true;
	}
	c = aa[c - 1], h--;
	return c >> h & 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...