#include "cmp.h"
void remember(int n) {
n += 4096;
while (n > 1){
bit_set(n);
n /= 4;
}
}
int kth(int num,int k){
k = 6 - k;
for (int i = 0; i < k; i++){ num /= 4; }
return num;
}
int compare(int b) {
int lo = 0;
int hi = 6;
int same = 1;
while (lo <= hi){
int mid = (lo + hi) / 2;
if (bit_get(kth(b, mid)) == 1) lo = mid + 1;
else { hi = mid - 1; same = 0; }
}
if (same) return 0;
int diff_pos = lo - 1;
int rem = kth(b, diff_pos);
if (rem % 4 == 0){
return -1;
}
else if (rem % 4 == 1){
return bit_get(rem / 4 * 4 + 0) ? 1 : -1;
}
else if (rem % 4 == 2){
return bit_get(rem / 4 * 4 + 3) ? -1 : 1;
}
else{
return 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1081 ms |
102232 KB |
ZERO POINTS: bit_get with address out of range |