# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
648719 |
2022-10-07T17:43:48 Z |
Johann |
cmp (balkan11_cmp) |
C++14 |
|
1834 ms |
82452 KB |
#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 BASE = 8;
const int LOG = ceil(log(4095) / log(BASE));
vi getDig(int x)
{
vi ans(LOG, 0);
for (int i = 0; i < LOG; ++i)
{
ans[i] = x % BASE;
x /= BASE;
}
return ans;
}
int addr(int pos, int digit)
{
return digit * LOG + pos + 1;
}
void print(vi &digits)
{
for (int d : digits)
printf("%d ", d);
printf("\n");
}
void remember(int n)
{
vi digits = getDig(n);
// print(ternary);
for (int i = 0; i < LOG; ++i)
bit_set(addr(i, digits[i]));
}
int compare(int b)
{
vi digits = getDig(b);
// print(ternary);
for (int i = LOG - 1; i >= 0; --i)
{
if (bit_get(addr(i, digits[i])))
continue;
if (digits[i] < BASE - digits[i])
{ // untere Hälfte checken...
for (int d = 0; d < digits[i]; ++d)
{
if (bit_get(addr(i, d)))
return 1;
}
return -1;
}
else
{
for (int d = BASE - 1; d > digits[i]; --d)
{
if (bit_get(addr(i, d)))
return -1;
}
return 1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1834 ms |
82452 KB |
Output is partially correct - maxAccess = 11, score = 91 |