// https://oj.uz/problem/view/balkan11_cmp > p151
#include "cmp.h"
#include <bits/stdc++.h>
using namespace std;
void remember(int n) {
int v[4];
for (int i=0; i<4; i++) {
for (int t=7; t>=0; t--) {
if (n >= (int)pow(8, 3-i) * t) {
v[i] = t;
n -= v[i] * (int)pow(8, 3-i);
break;
}
}
}
int idx = 1;
for (int i=0; i<4; i++) {
bit_set(v[i]+idx);
idx += 8;
}
}
int compare(int b) {
int v[4];
for (int i=0; i<4; i++) {
for (int t=7; t>=0; t--) {
if (b >= (int)pow(8, 3-i) * t) {
v[i] = t;
b -= v[i] * (int)pow(8, 3-i);
break;
}
}
}
int idx = 1;
for (int i=0; i<4; i++) {
if (bit_get(v[i]+idx)) {
// =
idx += 8;
} else {
if (v[i] >= 4) {
for (int test=v[i]+1; test <= 7; test++) {
if (bit_get(test+idx)) return -1;
}
return 1;
} else {
for (int test=v[i]-1; test >= 0; test--) {
if (bit_get(test+idx)) return 1;
}
return -1;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
8283 ms |
107036 KB |
Output is partially correct - maxAccess = 11, score = 91 |