Submission #114166

# Submission time Handle Problem Language Result Execution time Memory
114166 2019-05-31T06:20:33 Z mosesmayer Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
100 / 100
1318 ms 80496 KB
int encode (int n, int x, int y) {
	static int cnt = 0;
	static int tbl[1000];
	if (cnt == 0){
		for (int i = 0; i < (1<<12); i++){
			if (__builtin_popcount(i) == 6){
				tbl[++cnt] = i;
				if (cnt == 920) break;
			}
		}
	}
	int xx = tbl[x], yy = tbl[y];
	for (int i = 0; i < 12; i++){
		if (((xx >> i) & 1) == 1 && ((yy>>i)&1) == 0){
			return i + 1;
		}
	}
	return (x + y) % 2;
}
int decode (int n, int q, int h) {
	static int cnt = 0;
	static int tbl[1000];
	if (cnt == 0){
		for (int i = 0; i < (1<<12); i++){
			if (__builtin_popcount(i) == 6){
				tbl[++cnt] = i;
				if (cnt == 920) break;
			}
		}
	}
	int num = tbl[q];
	--h;
	return (num>>h)&1;
}
# Verdict Execution time Memory Grader output
1 Correct 1282 ms 80496 KB Output is correct - maxh = 12
2 Correct 1318 ms 80144 KB Output is correct - maxh = 12