#include "cmp.h"
// >> 8 & 15
// >> 5 & 7
// >> 2 & 7
// & 3
int shif[4] = { 8,5,2,0 };
int bi[4] = { 15,7,7,3 };
int base[4] = { 21,13,5,1 };
void remember(int n) {
//edit this
for (int i = 0; i < 4; i++)
bit_set(base[i] + ((n >> shif[i]) & bi[i]));
}
int compare(int b) {
//edit this
int cur[4] = { 0, };
for (int i = 0; i < 4; i++) {
cur[i] = (b >> shif[i]) & bi[i];
}
for (int i = 0; i < 4; i++) {
if (bit_get(base[i] + cur[i])) continue;
// cur[i] > half
// l = cur[i] + 1, r = max
// 여기서 1을 찾으면 a>b
if (cur[i] > bi[i] / 2) {
int l = base[i] + cur[i] + 1, r = base[i] + bi[i];
for (; l <= r; l++) {
if (bit_get(l)) return -1;
}
return 1;
}
// cur[i] <= half
// l = 0, r = cur[i]
// 여기서 1을 찾으면 b>a
int l = base[i] + 0, r = base[i] + cur[i] - 1;
for (; l <= r; l++) {
if (bit_get(l)) return 1;
}
return -1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1995 ms |
82548 KB |
Output is partially correct - maxAccess = 12, score = 82 |