# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130263 | 2019-07-14T12:24:25 Z | howard1005 | cmp (balkan11_cmp) | C++14 | 2217 ms | 89976 KB |
#include "cmp.h" typedef struct _bitr{ int min, max, idx1, idx2; }; _bitr bitr[10240]; void remember(int n) { int ntmp = n; int bi[12] = { 0, }; int i = 0, sum = 0; while (ntmp){ if (ntmp % 2){ bi[i] = 1; sum++; } i++; ntmp /= 2; } int bi_rev[12]; for (int a = 0; a < 12; a++) bi_rev[a] = bi[11 - a]; int flag = 0; if (sum > 6) { bit_set(10240); flag = 1; } int idx = 1; bitr[idx].min = 0; bitr[idx].max = 4095; for (int a = 0; a < 12; a++){ if (bi_rev[a]){ if (!flag) bit_set(idx); bitr[2 * idx + 1].min = (bitr[idx].max + bitr[idx].min) / 2 + 1; bitr[2 * idx + 1].max = bitr[idx].max; idx = 2 * idx + 1; } else{ if (flag) bit_set(idx); bitr[2 * idx].max = (bitr[idx].max + bitr[idx].min) / 2; bitr[2 * idx].min = bitr[idx].min; idx = 2 * idx; } } } int compare(int b) { int flag = bit_get(10240); int idx = 1; for (int a = 0; a < 12; a++){ if ((bit_get(idx) + flag) % 2){ idx = 2 * idx + 1; } else{ idx = 2 * idx; } if (b < bitr[idx].min) return -1; else if (bitr[idx].max < b) return 1; else if (bitr[idx].min == bitr[idx].max && bitr[idx].max == b) return 0; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 2217 ms | 89976 KB | Output is partially correct - maxAccess = 19, score = 19 |