# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095668 | idiotcomputer | cmp (balkan11_cmp) | C++11 | 0 ms | 0 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;
#define pb push_back
#define sz(x) (int) (x).size()
int ch[6] = {1, 5, 22, 87, 344, 1369};
int pw[6] = {1,4,16,64,256,1024};
void remember(int value){
int s = 0;
for (int i = 0; i < 6; i++){
s += pw[i] * (value%4);
bit_set(s+ch[i]);
value = value/4;
}
}
int compare(int value){
vector<int> res(6);
vector<int> cbit(6);
int s = 0;
int x;
for (int i = 0; i < 6; i++){
s += pw[i] * (value%4);
res[i] = s;
cbit[i] = value%4;
value = value/4;
}
int n = sz(res);
int l = -1;
int r = n;
while (r-l>1){
x = (l+r)/2;
if (bit_get(res[x]+ch[x])) l = x;
else r = x;
}
l++;
if (l == n) return 0;
if (cbit[l] == 0) return -1;
if (cbit[l] == 3) return 1;
if (cbit[l] == 1){
x = 0;
if (l > 0) x = res[l-1];
if (bit_get(x+ch[l])) return 1;
return -1;
}
x = 0;
if (l > 0) x = res[l-1];
x += pw[l]*3;
if (bit_get(x+ch[l])) return -1;
return 1;
}