Submission #7148

#TimeUsernameProblemLanguageResultExecution timeMemory
7148aintaQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++98
100 / 100
2629 ms25676 KiB
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 timeMemoryGrader output
Fetching results...