# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648723 | Johann | cmp (balkan11_cmp) | C++14 | 2461 ms | 82504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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()
vi bases = {6, 8, 10, 12};
vi getDig(int x)
{
vi ans(sz(bases), 0);
for (int i = 0; i < sz(bases); ++i)
{
ans[i] = x % bases[i];
x /= bases[i];
}
return ans;
}
int addr(int pos, int digit)
{
return digit * sz(bases) + 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 < sz(digits); ++i)
bit_set(addr(i, digits[i]));
}
int compare(int b)
{
vi digits = getDig(b);
// print(ternary);
for (int i = sz(digits) - 1; i >= 0; --i)
{
if (bit_get(addr(i, digits[i])))
continue;
if (digits[i] < bases[i] - 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 = bases[i] - 1; d > digits[i]; --d)
{
if (bit_get(addr(i, d)))
return -1;
}
return 1;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |