# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034221 | vjudge1 | cmp (balkan11_cmp) | C++17 | 10030 ms | 82516 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;
const int N = 4096;
int ans[N];
void remember(int n) {
for (int i = 0; i < 4096; i++) {
ans[i] = -2;
}
int x = __builtin_popcount(n);
if (x < 1 + 12-x) {
for (int i = 0; i <= 11; i++) {
if ((n >> i) & 1) bit_set(i+1);
}
}
else {
bit_set(13);
for (int i = 0; i <= 11; i++) {
if (!((n >> i) & 1)) bit_set(i+1);
}
}
}
int compare(int n) {
if (n && ans[n-1] == 1 && n+1 < 4096 && ans[n+1] == -1) {
return ans[n] = 0;
}
for (int i = 0; i < n; i++) {
if (ans[i] == -2) continue;
else if (ans[i] < 1) return ans[n] = -1;
}
for (int i = n+1; i < 4096; i++) {
if (ans[i] == -2) continue;
else if (ans[i] > -1) return ans[n] = 1;
}
int inv = bit_get(13);
for (int i = 11; i >= 0; i--) {
int x = bit_get(i+1);
if (inv) x = !x;
int y = (n >> i) & 1;
if (x > y) return -1;
else if (x < y) return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |