Submission #4695

#TimeUsernameProblemLanguageResultExecution timeMemory
4695tncks0121cmp (balkan11_cmp)C++98
100 / 100
2120 ms102264 KiB
#include "cmp.h" int cnt = 0; void remember(int n) { n += 4096; while(n > 1) { bit_set(n); n >>= 2; cnt ++; } } int compare(int b) { b += 4096; int low = 0, high = 6; int btop = -1; while(low <= high) { int mid = (low+high) >> 1; if(mid != 6 && !bit_get(b >> (mid*2))) { btop = b >> (mid*2); low = mid + 1; }else { high = mid - 1; } } if(btop == -1) return 0; switch(btop % 4) { case 0: return -1; case 3: return 1; case 1: return bit_get(btop/4*4+0) ? 1 : -1; case 2: return bit_get(btop/4*4+3) ? -1 : 1; } return 0; } /* lca __________ | | | | A B C D A에 있다: b < a D에 있다: b > a B에 있다: C에 있거나 D에 있다 C에 있다: A에 있거나 B에 있다 */
#Verdict Execution timeMemoryGrader output
Fetching results...