#include "cmp.h"
#include "bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
const int LOG3 = 8;
vi getTern(int x)
{
vi ans(LOG3, 0);
for (int i = 0; i < LOG3; ++i)
{
ans[i] = x % 3;
x /= 3;
}
return ans;
}
int addr(int pos, int digit)
{
return digit * LOG3 + pos + 1;
}
void print(vi &ternary)
{
for (int t : ternary)
printf("%d ", t);
printf("\n");
}
void remember(int n)
{
vi ternary = getTern(n);
// print(ternary);
for (int i = 0; i < LOG3; ++i)
bit_set(addr(i, ternary[i]));
}
int compare(int b)
{
vi ternary = getTern(b);
// print(ternary);
for (int i = LOG3 - 1; i >= 0; --i)
{
if (ternary[i] == 0)
{
if (bit_get(addr(i, 0)))
continue;
return -1;
}
else if (ternary[i] == 1)
{
if (bit_get(addr(i, 1)))
continue;
if (bit_get(addr(i, 0)))
return 1;
else
return -1;
}
else
{ // digit = 2
if (bit_get(addr(i, 2)))
continue;
return 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1993 ms |
82456 KB |
Output is partially correct - maxAccess = 17, score = 37 |