Submission #147946

#TimeUsernameProblemLanguageResultExecution timeMemory
147946evpipiscmp (balkan11_cmp)C++11
91 / 100
1593 ms82552 KiB
#include "cmp.h" const int lg = 12, k = 3; int match(int pos, int num){ return pos*(1<<k) + num + 1; } void remember(int a) { for (int pos = lg/k-1; pos >= 0; pos--){ int num = (a>>(k*pos))%(1<<k); bit_set(match(pos, num)); //printf("pos = %d, num = %d, match = %d\n", pos, num, match(pos, num)); } } int compare(int b) { for (int pos = lg/k-1; pos >= 0; pos--){ int num = (b>>(k*pos))%(1<<k); if (bit_get(match(pos, num))) continue; if (num < (1<<k)/2){ for (int j = 0; j < num; j++) if (bit_get(match(pos, j))) return 1; return -1; } else{ for (int j = (1<<k)-1; j > num; j--) if (bit_get(match(pos, j))) return -1; return 1; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...