#include "cmp.h"
//82점 비벼욧---!!!
//2bit compression
int getIdx(int n, int kth) {
kth *= 2; //2kth Idx
n >>= (kth - 2);
n %= 4;
return (10000 + (kth * 2) - 3 + n);
}
void remember(int n) {
for (int i = 6; i > 0; i--) bit_set(getIdx(n, i));
int up = (n >> 6) + 1;
bit_set(100 + up);
}
int compare(int b) {
int up = (b >> 6) + 1;
if (bit_get(100 + up)) {
for (int i = 3; i > 0; i--) {
int idx = getIdx(b, i);
if (bit_get(idx)) continue;
int c = (((idx - 10000) - 1) % 4) + 1;
switch(c) {
case 1:
return -1;
case 2:
if (bit_get(idx - 1)) return 1;
return -1;
case 3:
if (bit_get(idx + 1)) return -1;
return 1;
case 4:
return 1;
}
}
return 0;
}
else {
for (int i = 6; i > 3; i--) {
int idx = getIdx(b, i);
if (bit_get(idx)) continue;
int c = (((idx - 10000) - 1) % 4) + 1;
switch (c) {
case 1:
return -1;
case 2:
if (bit_get(idx - 1)) return 1;
return -1;
case 3:
if (bit_get(idx + 1)) return -1;
return 1;
case 4:
return 1;
}
}
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1825 ms |
83960 KB |
Output is partially correct - maxAccess = 12, score = 82 |