Submission #49564

#TimeUsernameProblemLanguageResultExecution timeMemory
49564tjd229cmp (balkan11_cmp)C++11
100 / 100
2710 ms95996 KiB
#include "cmp.h" void remember(int n) { //edit this int i; int a = n; int r[6]; for (i = 6; i--;){ r[i] = a % 4; a >>= 2; } for (a = i = 0; i < 6; i++){ a += r[i] + 1; bit_set(a); a <<= 2; } } int compare(int b) { //edit this int i; int r[6]; int pt[6]; int a = b; for (i = 6; i--;){ r[i] = a % 4; a >>= 2; } for (a = i = 0; i < 6; i++){ pt[i] = a = a + r[i] + 1; a <<= 2; } //bs int bnd = 0; int lo = 0; int hi = 6; while (lo <= hi){ int mid = (lo + hi) >> 1; if (mid == 6) return 0; if (bit_get(pt[mid])) lo = mid + 1; else hi = mid - 1; } bnd = lo; if (bnd == 6) return 0; //printf("switch\n"); switch (r[bnd]){ case 0: return -1; case 1: return bit_get(pt[bnd] - r[bnd] + 0) ? 1 : -1; case 2: return bit_get(pt[bnd] - r[bnd] + 3) ? -1 : 1; default: return 1; } return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...