Submission #7148

# Submission time Handle Problem Language Result Execution time Memory
7148 2014-07-26T13:14:33 Z ainta Question (Grader is different from the original contest) (CEOI14_question_grader) C++
100 / 100
2629 ms 25676 KB
static int C[13][13], w[13], p[13];
static void Do(int x){
	int i, c = 6;
	for (i = 12; i >= 1; i--){
		if (x > C[i - 1][c]){
			x -= C[i - 1][c];
			w[i] = 1; c--;
		}
		else{
			w[i] = 0;
		}
	}
}
int encode (int n, int x, int y) {
	int i, j;
	for (i = 0; i <= 12; i++){
		C[i][0] = 1;
		for (j = 1; j <= i; j++)C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	Do(x);
	for (i = 1; i <= 12; i++)p[i] = w[i];
	Do(y);
	for (i = 1; i <= 12; i++)if (p[i] && !w[i])break;
	return i;
}
static int C[13][13], w[13];
static void Do(int x){
	int i, c = 6;
	for (i = 12; i >= 1; i--){
		if (x > C[i - 1][c]){
			x -= C[i - 1][c];
			w[i] = 1; c--;
		}
		else{
			w[i] = 0;
		}
	}
}
int decode(int n, int q, int h) {
	int i, j;
	for (i = 0; i <= 12; i++){
		C[i][0] = 1;
		for (j = 1; j <= i; j++)C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
	}
	Do(q);
	if (w[h])return 1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2572 ms 25676 KB Output is correct - maxh = 12
2 Correct 2629 ms 25676 KB Output is correct - maxh = 12