# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4695 | tncks0121 | cmp (balkan11_cmp) | C++98 | 2120 ms | 102264 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |